1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2014 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\CampaignBundle\Entity; |
||
13 | |||
14 | use Doctrine\Common\Collections\ArrayCollection; |
||
15 | use Doctrine\Common\Collections\Criteria; |
||
16 | use Doctrine\ORM\Mapping as ORM; |
||
17 | use Mautic\ApiBundle\Serializer\Driver\ApiMetadataDriver; |
||
18 | use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; |
||
19 | use Mautic\LeadBundle\Entity\Lead as Contact; |
||
20 | |||
21 | /** |
||
22 | * Class Event. |
||
23 | */ |
||
24 | class Event implements ChannelInterface |
||
25 | { |
||
26 | const TYPE_DECISION = 'decision'; |
||
27 | const TYPE_ACTION = 'action'; |
||
28 | const TYPE_CONDITION = 'condition'; |
||
29 | |||
30 | const PATH_INACTION = 'no'; |
||
31 | const PATH_ACTION = 'yes'; |
||
32 | |||
33 | const TRIGGER_MODE_DATE = 'date'; |
||
34 | const TRIGGER_MODE_INTERVAL = 'interval'; |
||
35 | const TRIGGER_MODE_IMMEDIATE = 'immediate'; |
||
36 | |||
37 | const CHANNEL_EMAIL = 'email'; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | */ |
||
42 | private $id; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | private $name; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | private $description; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | private $type; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | private $eventType; |
||
63 | |||
64 | /** |
||
65 | * @var int |
||
66 | */ |
||
67 | private $order = 0; |
||
68 | |||
69 | /** |
||
70 | * @var array |
||
71 | */ |
||
72 | private $properties = []; |
||
73 | |||
74 | /** |
||
75 | * @var \DateTime|null |
||
76 | */ |
||
77 | private $triggerDate; |
||
78 | |||
79 | /** |
||
80 | * @var int |
||
81 | */ |
||
82 | private $triggerInterval = 0; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | */ |
||
87 | private $triggerIntervalUnit; |
||
88 | |||
89 | /** |
||
90 | * @var \DateTime|null |
||
91 | */ |
||
92 | private $triggerHour; |
||
93 | |||
94 | /** |
||
95 | * @var \DateTime|null |
||
96 | */ |
||
97 | private $triggerRestrictedStartHour; |
||
98 | |||
99 | /** |
||
100 | * @var \DateTime|null |
||
101 | */ |
||
102 | private $triggerRestrictedStopHour; |
||
103 | |||
104 | /** |
||
105 | * @var array|null |
||
106 | */ |
||
107 | private $triggerRestrictedDaysOfWeek = []; |
||
108 | |||
109 | /** |
||
110 | * @var string |
||
111 | */ |
||
112 | private $triggerMode; |
||
113 | |||
114 | /** |
||
115 | * @var Campaign |
||
116 | */ |
||
117 | private $campaign; |
||
118 | |||
119 | /** |
||
120 | * @var ArrayCollection |
||
121 | **/ |
||
122 | private $children; |
||
123 | |||
124 | /** |
||
125 | * @var Event |
||
126 | **/ |
||
127 | private $parent; |
||
128 | |||
129 | /** |
||
130 | * @var string |
||
131 | **/ |
||
132 | private $decisionPath; |
||
133 | |||
134 | /** |
||
135 | * @var string |
||
136 | **/ |
||
137 | private $tempId; |
||
138 | |||
139 | /** |
||
140 | * @var ArrayCollection |
||
141 | */ |
||
142 | private $log; |
||
143 | |||
144 | /** |
||
145 | * Used by API to house contact specific logs. |
||
146 | * |
||
147 | * @var array |
||
148 | */ |
||
149 | private $contactLog = []; |
||
150 | |||
151 | /** |
||
152 | * @var string|null |
||
153 | */ |
||
154 | private $channel; |
||
155 | |||
156 | /** |
||
157 | * @var int|null |
||
158 | */ |
||
159 | private $channelId; |
||
160 | |||
161 | /** |
||
162 | * @var array |
||
163 | */ |
||
164 | private $changes = []; |
||
165 | |||
166 | public function __construct() |
||
167 | { |
||
168 | $this->log = new ArrayCollection(); |
||
169 | $this->children = new ArrayCollection(); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * Clean up after clone. |
||
174 | */ |
||
175 | public function __clone() |
||
176 | { |
||
177 | $this->tempId = null; |
||
178 | $this->campaign = null; |
||
179 | $this->channel = null; |
||
180 | $this->channelId = null; |
||
181 | } |
||
182 | |||
183 | public static function loadMetadata(ORM\ClassMetadata $metadata) |
||
184 | { |
||
185 | $builder = new ClassMetadataBuilder($metadata); |
||
186 | |||
187 | $builder->setTable('campaign_events') |
||
188 | ->setCustomRepositoryClass('Mautic\CampaignBundle\Entity\EventRepository') |
||
189 | ->addIndex(['type', 'event_type'], 'campaign_event_search') |
||
190 | ->addIndex(['event_type'], 'campaign_event_type') |
||
191 | ->addIndex(['channel', 'channel_id'], 'campaign_event_channel'); |
||
192 | |||
193 | $builder->addIdColumns(); |
||
194 | |||
195 | $builder->createField('type', 'string') |
||
196 | ->length(50) |
||
197 | ->build(); |
||
198 | |||
199 | $builder->createField('eventType', 'string') |
||
200 | ->columnName('event_type') |
||
201 | ->length(50) |
||
202 | ->build(); |
||
203 | |||
204 | $builder->createField('order', 'integer') |
||
205 | ->columnName('event_order') |
||
206 | ->build(); |
||
207 | |||
208 | $builder->addField('properties', 'array'); |
||
209 | |||
210 | $builder->createField('triggerDate', 'datetime') |
||
211 | ->columnName('trigger_date') |
||
212 | ->nullable() |
||
213 | ->build(); |
||
214 | |||
215 | $builder->createField('triggerInterval', 'integer') |
||
216 | ->columnName('trigger_interval') |
||
217 | ->nullable() |
||
218 | ->build(); |
||
219 | |||
220 | $builder->createField('triggerIntervalUnit', 'string') |
||
221 | ->columnName('trigger_interval_unit') |
||
222 | ->length(1) |
||
223 | ->nullable() |
||
224 | ->build(); |
||
225 | |||
226 | $builder->createField('triggerHour', 'time') |
||
227 | ->columnName('trigger_hour') |
||
228 | ->nullable() |
||
229 | ->build(); |
||
230 | |||
231 | $builder->createField('triggerRestrictedStartHour', 'time') |
||
232 | ->columnName('trigger_restricted_start_hour') |
||
233 | ->nullable() |
||
234 | ->build(); |
||
235 | |||
236 | $builder->createField('triggerRestrictedStopHour', 'time') |
||
237 | ->columnName('trigger_restricted_stop_hour') |
||
238 | ->nullable() |
||
239 | ->build(); |
||
240 | |||
241 | $builder->createField('triggerRestrictedDaysOfWeek', 'array') |
||
242 | ->columnName('trigger_restricted_dow') |
||
243 | ->nullable() |
||
244 | ->build(); |
||
245 | |||
246 | $builder->createField('triggerMode', 'string') |
||
247 | ->columnName('trigger_mode') |
||
248 | ->length(10) |
||
249 | ->nullable() |
||
250 | ->build(); |
||
251 | |||
252 | $builder->createManyToOne('campaign', 'Campaign') |
||
253 | ->inversedBy('events') |
||
254 | ->addJoinColumn('campaign_id', 'id', false, false, 'CASCADE') |
||
255 | ->build(); |
||
256 | |||
257 | $builder->createOneToMany('children', 'Event') |
||
258 | ->setIndexBy('id') |
||
259 | ->setOrderBy(['order' => 'ASC']) |
||
260 | ->mappedBy('parent') |
||
261 | ->build(); |
||
262 | |||
263 | $builder->createManyToOne('parent', 'Event') |
||
264 | ->inversedBy('children') |
||
265 | ->cascadePersist() |
||
266 | ->addJoinColumn('parent_id', 'id') |
||
267 | ->build(); |
||
268 | |||
269 | $builder->createField('decisionPath', 'string') |
||
270 | ->columnName('decision_path') |
||
271 | ->nullable() |
||
272 | ->build(); |
||
273 | |||
274 | $builder->createField('tempId', 'string') |
||
275 | ->columnName('temp_id') |
||
276 | ->nullable() |
||
277 | ->build(); |
||
278 | |||
279 | $builder->createOneToMany('log', 'LeadEventLog') |
||
280 | ->mappedBy('event') |
||
281 | ->cascadePersist() |
||
282 | ->cascadeRemove() |
||
283 | ->fetchExtraLazy() |
||
284 | ->build(); |
||
285 | |||
286 | $builder->createField('channel', 'string') |
||
287 | ->nullable() |
||
288 | ->build(); |
||
289 | |||
290 | $builder->createField('channelId', 'integer') |
||
291 | ->columnName('channel_id') |
||
292 | ->nullable() |
||
293 | ->build(); |
||
294 | } |
||
295 | |||
296 | /** |
||
297 | * Prepares the metadata for API usage. |
||
298 | * |
||
299 | * @param $metadata |
||
300 | */ |
||
301 | public static function loadApiMetadata(ApiMetadataDriver $metadata) |
||
302 | { |
||
303 | $metadata->setGroupPrefix('campaignEvent') |
||
304 | ->addListProperties( |
||
305 | [ |
||
306 | 'id', |
||
307 | 'name', |
||
308 | 'description', |
||
309 | 'type', |
||
310 | 'eventType', |
||
311 | 'channel', |
||
312 | 'channelId', |
||
313 | ] |
||
314 | ) |
||
315 | ->addProperties( |
||
316 | [ |
||
317 | 'order', |
||
318 | 'properties', |
||
319 | 'triggerDate', |
||
320 | 'triggerInterval', |
||
321 | 'triggerIntervalUnit', |
||
322 | 'triggerHour', |
||
323 | 'triggerRestrictedStartHour', |
||
324 | 'triggerRestrictedStopHour', |
||
325 | 'triggerRestrictedDaysOfWeek', |
||
326 | 'triggerMode', |
||
327 | 'decisionPath', |
||
328 | 'channel', |
||
329 | 'channelId', |
||
330 | 'parent', |
||
331 | 'children', |
||
332 | ] |
||
333 | ) |
||
334 | ->setMaxDepth(1, 'parent') |
||
335 | ->setMaxDepth(1, 'children') |
||
336 | |||
337 | // Add standalone groups |
||
338 | ->setGroupPrefix('campaignEventStandalone') |
||
339 | ->addListProperties( |
||
340 | [ |
||
341 | 'id', |
||
342 | 'name', |
||
343 | 'description', |
||
344 | 'type', |
||
345 | 'eventType', |
||
346 | 'channel', |
||
347 | 'channelId', |
||
348 | ] |
||
349 | ) |
||
350 | ->addProperties( |
||
351 | [ |
||
352 | 'campaign', |
||
353 | 'order', |
||
354 | 'properties', |
||
355 | 'triggerDate', |
||
356 | 'triggerInterval', |
||
357 | 'triggerIntervalUnit', |
||
358 | 'triggerHour', |
||
359 | 'triggerRestrictedStartHour', |
||
360 | 'triggerRestrictedStopHour', |
||
361 | 'triggerRestrictedDaysOfWeek', |
||
362 | 'triggerMode', |
||
363 | 'children', |
||
364 | 'parent', |
||
365 | 'decisionPath', |
||
366 | ] |
||
367 | ) |
||
368 | |||
369 | // Include logs |
||
370 | ->setGroupPrefix('campaignEventWithLogs') |
||
371 | ->addListProperties( |
||
372 | [ |
||
373 | 'id', |
||
374 | 'name', |
||
375 | 'description', |
||
376 | 'type', |
||
377 | 'eventType', |
||
378 | 'contactLog', |
||
379 | 'triggerDate', |
||
380 | 'triggerInterval', |
||
381 | 'triggerIntervalUnit', |
||
382 | 'triggerHour', |
||
383 | 'triggerRestrictedStartHour', |
||
384 | 'triggerRestrictedStopHour', |
||
385 | 'triggerRestrictedDaysOfWeek', |
||
386 | 'triggerMode', |
||
387 | 'decisionPath', |
||
388 | 'order', |
||
389 | 'parent', |
||
390 | 'channel', |
||
391 | 'channelId', |
||
392 | ] |
||
393 | ) |
||
394 | ->addProperties( |
||
395 | [ |
||
396 | 'campaign', |
||
397 | ] |
||
398 | ) |
||
399 | ->build(); |
||
400 | } |
||
401 | |||
402 | /** |
||
403 | * @param string $prop |
||
404 | * @param mixed $val |
||
405 | */ |
||
406 | private function isChanged($prop, $val) |
||
407 | { |
||
408 | $getter = 'get'.ucfirst($prop); |
||
409 | $current = $this->$getter(); |
||
410 | if ('category' == $prop || 'parent' == $prop) { |
||
411 | $currentId = ($current) ? $current->getId() : ''; |
||
412 | $newId = ($val) ? $val->getId() : null; |
||
413 | if ($currentId != $newId) { |
||
414 | $this->changes[$prop] = [$currentId, $newId]; |
||
415 | } |
||
416 | } elseif ($this->$prop != $val) { |
||
417 | $this->changes[$prop] = [$this->$prop, $val]; |
||
418 | } |
||
419 | } |
||
420 | |||
421 | /** |
||
422 | * @return array |
||
423 | */ |
||
424 | public function getChanges() |
||
425 | { |
||
426 | return $this->changes; |
||
427 | } |
||
428 | |||
429 | /** |
||
430 | * Get id. |
||
431 | * |
||
432 | * @return int |
||
433 | */ |
||
434 | public function getId() |
||
435 | { |
||
436 | return $this->id; |
||
437 | } |
||
438 | |||
439 | public function nullId() |
||
440 | { |
||
441 | $this->id = null; |
||
442 | } |
||
443 | |||
444 | /** |
||
445 | * Set order. |
||
446 | * |
||
447 | * @param int $order |
||
448 | * |
||
449 | * @return Event |
||
450 | */ |
||
451 | public function setOrder($order) |
||
452 | { |
||
453 | $this->isChanged('order', $order); |
||
454 | |||
455 | $this->order = $order; |
||
456 | |||
457 | return $this; |
||
458 | } |
||
459 | |||
460 | /** |
||
461 | * Get order. |
||
462 | * |
||
463 | * @return int |
||
464 | */ |
||
465 | public function getOrder() |
||
466 | { |
||
467 | return $this->order; |
||
468 | } |
||
469 | |||
470 | /** |
||
471 | * Set properties. |
||
472 | * |
||
473 | * @param array $properties |
||
474 | * |
||
475 | * @return Event |
||
476 | */ |
||
477 | public function setProperties($properties) |
||
478 | { |
||
479 | $this->isChanged('properties', $properties); |
||
480 | |||
481 | $this->properties = $properties; |
||
482 | |||
483 | return $this; |
||
484 | } |
||
485 | |||
486 | /** |
||
487 | * Get properties. |
||
488 | * |
||
489 | * @return array |
||
490 | */ |
||
491 | public function getProperties() |
||
492 | { |
||
493 | return $this->properties; |
||
494 | } |
||
495 | |||
496 | /** |
||
497 | * Set campaign. |
||
498 | * |
||
499 | * @return Event |
||
500 | */ |
||
501 | public function setCampaign(\Mautic\CampaignBundle\Entity\Campaign $campaign) |
||
502 | { |
||
503 | $this->campaign = $campaign; |
||
504 | |||
505 | return $this; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * Get campaign. |
||
510 | * |
||
511 | * @return \Mautic\CampaignBundle\Entity\Campaign |
||
512 | */ |
||
513 | public function getCampaign() |
||
514 | { |
||
515 | return $this->campaign; |
||
516 | } |
||
517 | |||
518 | /** |
||
519 | * Set type. |
||
520 | * |
||
521 | * @param string $type |
||
522 | * |
||
523 | * @return Event |
||
524 | */ |
||
525 | public function setType($type) |
||
526 | { |
||
527 | $this->isChanged('type', $type); |
||
528 | $this->type = $type; |
||
529 | |||
530 | return $this; |
||
531 | } |
||
532 | |||
533 | /** |
||
534 | * Get type. |
||
535 | * |
||
536 | * @return string |
||
537 | */ |
||
538 | public function getType() |
||
539 | { |
||
540 | return $this->type; |
||
541 | } |
||
542 | |||
543 | /** |
||
544 | * @return array |
||
545 | */ |
||
546 | public function convertToArray() |
||
547 | { |
||
548 | return get_object_vars($this); |
||
549 | } |
||
550 | |||
551 | /** |
||
552 | * Set description. |
||
553 | * |
||
554 | * @param string $description |
||
555 | * |
||
556 | * @return Event |
||
557 | */ |
||
558 | public function setDescription($description) |
||
559 | { |
||
560 | $this->isChanged('description', $description); |
||
561 | $this->description = $description; |
||
562 | |||
563 | return $this; |
||
564 | } |
||
565 | |||
566 | /** |
||
567 | * Get description. |
||
568 | * |
||
569 | * @return string |
||
570 | */ |
||
571 | public function getDescription() |
||
572 | { |
||
573 | return $this->description; |
||
574 | } |
||
575 | |||
576 | /** |
||
577 | * Set name. |
||
578 | * |
||
579 | * @param string $name |
||
580 | * |
||
581 | * @return Event |
||
582 | */ |
||
583 | public function setName($name) |
||
584 | { |
||
585 | $this->isChanged('name', $name); |
||
586 | $this->name = $name; |
||
587 | |||
588 | return $this; |
||
589 | } |
||
590 | |||
591 | /** |
||
592 | * Get name. |
||
593 | * |
||
594 | * @return string |
||
595 | */ |
||
596 | public function getName() |
||
597 | { |
||
598 | return $this->name; |
||
599 | } |
||
600 | |||
601 | /** |
||
602 | * Add log. |
||
603 | * |
||
604 | * @return Event |
||
605 | */ |
||
606 | public function addLog(LeadEventLog $log) |
||
607 | { |
||
608 | $this->log[] = $log; |
||
609 | |||
610 | return $this; |
||
611 | } |
||
612 | |||
613 | /** |
||
614 | * Remove log. |
||
615 | */ |
||
616 | public function removeLog(LeadEventLog $log) |
||
617 | { |
||
618 | $this->log->removeElement($log); |
||
619 | } |
||
620 | |||
621 | /** |
||
622 | * Get log. |
||
623 | * |
||
624 | * @return \Doctrine\Common\Collections\Collection |
||
625 | */ |
||
626 | public function getLog() |
||
627 | { |
||
628 | return $this->log; |
||
629 | } |
||
630 | |||
631 | /** |
||
632 | * Get log for a contact and a rotation. |
||
633 | * |
||
634 | * @param $rotation |
||
635 | * |
||
636 | * @return LeadEventLog|null |
||
637 | */ |
||
638 | public function getLogByContactAndRotation(Contact $contact, $rotation) |
||
639 | { |
||
640 | $criteria = Criteria::create() |
||
641 | ->where(Criteria::expr()->eq('lead', $contact)) |
||
642 | ->andWhere(Criteria::expr()->eq('rotation', $rotation)) |
||
643 | ->setMaxResults(1); |
||
644 | |||
645 | $log = $this->getLog()->matching($criteria); |
||
646 | |||
647 | if (count($log)) { |
||
648 | return $log->first(); |
||
649 | } |
||
650 | |||
651 | return null; |
||
652 | } |
||
653 | |||
654 | /** |
||
655 | * Add children. |
||
656 | * |
||
657 | * @param \Mautic\CampaignBundle\Entity\Event $children |
||
658 | * |
||
659 | * @return Event |
||
660 | */ |
||
661 | public function addChild(Event $children) |
||
662 | { |
||
663 | $this->children[] = $children; |
||
664 | |||
665 | return $this; |
||
666 | } |
||
667 | |||
668 | /** |
||
669 | * Remove children. |
||
670 | * |
||
671 | * @param \Mautic\CampaignBundle\Entity\Event $children |
||
672 | */ |
||
673 | public function removeChild(Event $children) |
||
674 | { |
||
675 | $this->children->removeElement($children); |
||
676 | } |
||
677 | |||
678 | /** |
||
679 | * @return ArrayCollection|Event[] |
||
680 | */ |
||
681 | public function getChildren() |
||
682 | { |
||
683 | return $this->children; |
||
684 | } |
||
685 | |||
686 | /** |
||
687 | * @return ArrayCollection|Event[] |
||
688 | */ |
||
689 | public function getPositiveChildren() |
||
690 | { |
||
691 | $criteria = Criteria::create()->where(Criteria::expr()->eq('decisionPath', self::PATH_ACTION)); |
||
692 | |||
693 | return $this->getChildren()->matching($criteria); |
||
694 | } |
||
695 | |||
696 | /** |
||
697 | * @return ArrayCollection|Event[] |
||
698 | */ |
||
699 | public function getNegativeChildren() |
||
700 | { |
||
701 | $criteria = Criteria::create()->where(Criteria::expr()->eq('decisionPath', self::PATH_INACTION)); |
||
702 | |||
703 | return $this->getChildren()->matching($criteria); |
||
704 | } |
||
705 | |||
706 | /** |
||
707 | * @param $type |
||
708 | * |
||
709 | * @return ArrayCollection |
||
710 | */ |
||
711 | public function getChildrenByType($type) |
||
712 | { |
||
713 | $criteria = Criteria::create()->where(Criteria::expr()->eq('type', $type)); |
||
714 | |||
715 | return $this->getChildren()->matching($criteria); |
||
716 | } |
||
717 | |||
718 | /** |
||
719 | * @param $type |
||
720 | * |
||
721 | * @return ArrayCollection |
||
722 | */ |
||
723 | public function getChildrenByEventType($type) |
||
724 | { |
||
725 | $criteria = Criteria::create()->where(Criteria::expr()->eq('eventType', $type)); |
||
726 | |||
727 | return $this->getChildren()->matching($criteria); |
||
728 | } |
||
729 | |||
730 | /** |
||
731 | * Set parent. |
||
732 | * |
||
733 | * @param \Mautic\CampaignBundle\Entity\Event $parent |
||
734 | * |
||
735 | * @return Event |
||
736 | */ |
||
737 | public function setParent(Event $parent = null) |
||
738 | { |
||
739 | $this->isChanged('parent', $parent); |
||
740 | $this->parent = $parent; |
||
741 | |||
742 | return $this; |
||
743 | } |
||
744 | |||
745 | /** |
||
746 | * Remove parent. |
||
747 | */ |
||
748 | public function removeParent() |
||
749 | { |
||
750 | $this->isChanged('parent', ''); |
||
751 | $this->parent = null; |
||
752 | } |
||
753 | |||
754 | /** |
||
755 | * Get parent. |
||
756 | * |
||
757 | * @return \Mautic\CampaignBundle\Entity\Event |
||
758 | */ |
||
759 | public function getParent() |
||
760 | { |
||
761 | return $this->parent; |
||
762 | } |
||
763 | |||
764 | /** |
||
765 | * @return mixed |
||
766 | */ |
||
767 | public function getTriggerDate() |
||
768 | { |
||
769 | return $this->triggerDate; |
||
770 | } |
||
771 | |||
772 | /** |
||
773 | * @param mixed $triggerDate |
||
774 | */ |
||
775 | public function setTriggerDate($triggerDate) |
||
776 | { |
||
777 | $this->isChanged('triggerDate', $triggerDate); |
||
778 | $this->triggerDate = $triggerDate; |
||
779 | } |
||
780 | |||
781 | /** |
||
782 | * @return int |
||
783 | */ |
||
784 | public function getTriggerInterval() |
||
785 | { |
||
786 | return $this->triggerInterval; |
||
787 | } |
||
788 | |||
789 | /** |
||
790 | * @param int $triggerInterval |
||
791 | */ |
||
792 | public function setTriggerInterval($triggerInterval) |
||
793 | { |
||
794 | $this->isChanged('triggerInterval', $triggerInterval); |
||
795 | $this->triggerInterval = $triggerInterval; |
||
796 | } |
||
797 | |||
798 | /** |
||
799 | * @return \DateTime |
||
800 | */ |
||
801 | public function getTriggerHour() |
||
802 | { |
||
803 | return $this->triggerHour; |
||
804 | } |
||
805 | |||
806 | /** |
||
807 | * @param string $triggerHour |
||
808 | * |
||
809 | * @return Event |
||
810 | */ |
||
811 | public function setTriggerHour($triggerHour) |
||
812 | { |
||
813 | if (empty($triggerHour)) { |
||
814 | $triggerHour = null; |
||
815 | } elseif (!$triggerHour instanceof \DateTime) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
816 | $triggerHour = new \DateTime($triggerHour); |
||
817 | } |
||
818 | |||
819 | $this->isChanged('triggerHour', $triggerHour ? $triggerHour->format('H:i') : $triggerHour); |
||
820 | $this->triggerHour = $triggerHour; |
||
821 | |||
822 | return $this; |
||
823 | } |
||
824 | |||
825 | /** |
||
826 | * @return mixed |
||
827 | */ |
||
828 | public function getTriggerIntervalUnit() |
||
829 | { |
||
830 | return $this->triggerIntervalUnit; |
||
831 | } |
||
832 | |||
833 | /** |
||
834 | * @param mixed $triggerIntervalUnit |
||
835 | */ |
||
836 | public function setTriggerIntervalUnit($triggerIntervalUnit) |
||
837 | { |
||
838 | $this->isChanged('triggerIntervalUnit', $triggerIntervalUnit); |
||
839 | $this->triggerIntervalUnit = $triggerIntervalUnit; |
||
840 | } |
||
841 | |||
842 | /** |
||
843 | * @return mixed |
||
844 | */ |
||
845 | public function getEventType() |
||
846 | { |
||
847 | return $this->eventType; |
||
848 | } |
||
849 | |||
850 | /** |
||
851 | * @param $eventType |
||
852 | * |
||
853 | * @return $this |
||
854 | */ |
||
855 | public function setEventType($eventType) |
||
856 | { |
||
857 | $this->isChanged('eventType', $eventType); |
||
858 | $this->eventType = $eventType; |
||
859 | |||
860 | return $this; |
||
861 | } |
||
862 | |||
863 | /** |
||
864 | * @return mixed |
||
865 | */ |
||
866 | public function getTriggerMode() |
||
867 | { |
||
868 | return $this->triggerMode; |
||
869 | } |
||
870 | |||
871 | /** |
||
872 | * @param mixed $triggerMode |
||
873 | */ |
||
874 | public function setTriggerMode($triggerMode) |
||
875 | { |
||
876 | $this->isChanged('triggerMode', $triggerMode); |
||
877 | $this->triggerMode = $triggerMode; |
||
878 | } |
||
879 | |||
880 | /** |
||
881 | * @return mixed |
||
882 | */ |
||
883 | public function getDecisionPath() |
||
884 | { |
||
885 | return $this->decisionPath; |
||
886 | } |
||
887 | |||
888 | /** |
||
889 | * @param mixed $decisionPath |
||
890 | */ |
||
891 | public function setDecisionPath($decisionPath) |
||
892 | { |
||
893 | $this->isChanged('decisionPath', $decisionPath); |
||
894 | $this->decisionPath = $decisionPath; |
||
895 | } |
||
896 | |||
897 | /** |
||
898 | * @return mixed |
||
899 | */ |
||
900 | public function getTempId() |
||
901 | { |
||
902 | return $this->tempId; |
||
903 | } |
||
904 | |||
905 | /** |
||
906 | * @param mixed $tempId |
||
907 | */ |
||
908 | public function setTempId($tempId) |
||
909 | { |
||
910 | $this->isChanged('tempId', $tempId); |
||
911 | $this->tempId = $tempId; |
||
912 | } |
||
913 | |||
914 | /** |
||
915 | * @return mixed |
||
916 | */ |
||
917 | public function getChannel() |
||
918 | { |
||
919 | return $this->channel; |
||
920 | } |
||
921 | |||
922 | /** |
||
923 | * @param mixed $channel |
||
924 | */ |
||
925 | public function setChannel($channel) |
||
926 | { |
||
927 | $this->isChanged('channel', $channel); |
||
928 | $this->channel = $channel; |
||
929 | } |
||
930 | |||
931 | /** |
||
932 | * @return int |
||
933 | */ |
||
934 | public function getChannelId() |
||
935 | { |
||
936 | return $this->channelId; |
||
937 | } |
||
938 | |||
939 | /** |
||
940 | * @param int $channelId |
||
941 | */ |
||
942 | public function setChannelId($channelId) |
||
943 | { |
||
944 | $this->isChanged('channelId', $channelId); |
||
945 | $this->channelId = (int) $channelId; |
||
946 | } |
||
947 | |||
948 | /** |
||
949 | * Used by the API. |
||
950 | * |
||
951 | * @return LeadEventLog[]|\Doctrine\Common\Collections\Collection|static |
||
952 | */ |
||
953 | public function getContactLog(Contact $contact = null) |
||
954 | { |
||
955 | if ($this->contactLog) { |
||
956 | return $this->contactLog; |
||
957 | } |
||
958 | |||
959 | return $this->log->matching( |
||
960 | Criteria::create() |
||
961 | ->where( |
||
962 | Criteria::expr()->eq('lead', $contact) |
||
963 | ) |
||
964 | ); |
||
965 | } |
||
966 | |||
967 | /** |
||
968 | * Used by the API. |
||
969 | * |
||
970 | * @param array $contactLog |
||
971 | * |
||
972 | * @return Event |
||
973 | */ |
||
974 | public function setContactLog($contactLog) |
||
975 | { |
||
976 | $this->contactLog = $contactLog; |
||
977 | |||
978 | return $this; |
||
979 | } |
||
980 | |||
981 | /** |
||
982 | * Used by the API. |
||
983 | * |
||
984 | * @return Event |
||
985 | */ |
||
986 | public function addContactLog($contactLog) |
||
987 | { |
||
988 | $this->contactLog[] = $contactLog; |
||
989 | |||
990 | return $this; |
||
991 | } |
||
992 | |||
993 | /** |
||
994 | * Get the value of triggerRestrictedStartHour. |
||
995 | * |
||
996 | * @return \DateTime|null |
||
997 | */ |
||
998 | public function getTriggerRestrictedStartHour() |
||
999 | { |
||
1000 | return $this->triggerRestrictedStartHour; |
||
1001 | } |
||
1002 | |||
1003 | /** |
||
1004 | * Set the value of triggerRestrictedStartHour. |
||
1005 | * |
||
1006 | * @param \DateTime|null $triggerRestrictedStartHour |
||
1007 | * |
||
1008 | * @return self |
||
1009 | */ |
||
1010 | public function setTriggerRestrictedStartHour($triggerRestrictedStartHour) |
||
1011 | { |
||
1012 | if (empty($triggerRestrictedStartHour)) { |
||
1013 | $triggerRestrictedStartHour = null; |
||
1014 | } elseif (!$triggerRestrictedStartHour instanceof \DateTime) { |
||
0 ignored issues
–
show
|
|||
1015 | $triggerRestrictedStartHour = new \DateTime($triggerRestrictedStartHour); |
||
1016 | } |
||
1017 | |||
1018 | $this->isChanged('triggerRestrictedStartHour', $triggerRestrictedStartHour ? $triggerRestrictedStartHour->format('H:i') : $triggerRestrictedStartHour); |
||
1019 | |||
1020 | $this->triggerRestrictedStartHour = $triggerRestrictedStartHour; |
||
1021 | |||
1022 | return $this; |
||
1023 | } |
||
1024 | |||
1025 | /** |
||
1026 | * Get the value of triggerRestrictedStopHour. |
||
1027 | * |
||
1028 | * @return \DateTime|null |
||
1029 | */ |
||
1030 | public function getTriggerRestrictedStopHour() |
||
1031 | { |
||
1032 | return $this->triggerRestrictedStopHour; |
||
1033 | } |
||
1034 | |||
1035 | /** |
||
1036 | * Set the value of triggerRestrictedStopHour. |
||
1037 | * |
||
1038 | * @param \DateTime|null $triggerRestrictedStopHour |
||
1039 | * |
||
1040 | * @return self |
||
1041 | */ |
||
1042 | public function setTriggerRestrictedStopHour($triggerRestrictedStopHour) |
||
1043 | { |
||
1044 | if (empty($triggerRestrictedStopHour)) { |
||
1045 | $triggerRestrictedStopHour = null; |
||
1046 | } elseif (!$triggerRestrictedStopHour instanceof \DateTime) { |
||
0 ignored issues
–
show
|
|||
1047 | $triggerRestrictedStopHour = new \DateTime($triggerRestrictedStopHour); |
||
1048 | } |
||
1049 | |||
1050 | $this->isChanged('triggerRestrictedStopHour', $triggerRestrictedStopHour ? $triggerRestrictedStopHour->format('H:i') : $triggerRestrictedStopHour); |
||
1051 | |||
1052 | $this->triggerRestrictedStopHour = $triggerRestrictedStopHour; |
||
1053 | |||
1054 | return $this; |
||
1055 | } |
||
1056 | |||
1057 | /** |
||
1058 | * Get the value of triggerRestrictedDaysOfWeek. |
||
1059 | * |
||
1060 | * @return array |
||
1061 | */ |
||
1062 | public function getTriggerRestrictedDaysOfWeek() |
||
1063 | { |
||
1064 | return (array) $this->triggerRestrictedDaysOfWeek; |
||
1065 | } |
||
1066 | |||
1067 | /** |
||
1068 | * Set the value of triggerRestrictedDaysOfWeek. |
||
1069 | * |
||
1070 | * @return self |
||
1071 | */ |
||
1072 | public function setTriggerRestrictedDaysOfWeek(array $triggerRestrictedDaysOfWeek = null) |
||
1073 | { |
||
1074 | $this->triggerRestrictedDaysOfWeek = $triggerRestrictedDaysOfWeek; |
||
1075 | $this->isChanged('triggerRestrictedDaysOfWeek', $triggerRestrictedDaysOfWeek); |
||
1076 | |||
1077 | return $this; |
||
1078 | } |
||
1079 | } |
||
1080 |