| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace cx_newsletter;
- class campaign_builder
- extends builder
- implements builder_interface {
- protected function prepare() : void {
- $this->target = new campaign();
- }
- public function set_type(campaign_type $type) : self {
- $this->target->type = $type;
- if ($this->target->is_complete()) {
- $this->complete();
- }
- return $this;
- }
- public function set_message(message $message) : self {
- if (!$message->has_id()) {
- throw new \exception('Message to set for campaign must has ID.');
- }
- $this->target->message = $message;
- if ($this->target->is_complete()) {
- $this->complete();
- }
- return $this;
- }
- public function set_group(group $group) : self {
- $this->target->group = $group;
- if ($this->target->is_complete()) {
- $this->complete();
- }
- return $this;
- }
- public function set_test(bool $test = true) : self {
- $this->target->test = $test;
- if ($this->target->is_complete()) {
- $this->complete();
- }
-
- return $this;
- }
- }
|