Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
method.php
1<?php
9
11
14
15Loc::loadMessages(__FILE__);
16
21class Method implements iMethod
22{
23 const DEFERED = 'defered';
24 const TIME = 'time';
25 const SCHEDULE = 'schedule';
26
28 private $letter;
29
31 private $method;
32
38 public function __construct(Entity\Letter $letter)
39 {
40 $this->letter = $letter;
41
42 if ($letter->isReiterate())
43 {
44 $this->set(new MethodSchedule($this->letter));
45 }
46 elseif($this->letter->get('AUTO_SEND_TIME'))
47 {
48 $this->time($this->letter->get('AUTO_SEND_TIME'));
49 }
50 else
51 {
52 $this->defer();
53 }
54
55 }
56
62 public function canChange()
63 {
64 return (
65 (
66 $this->letter->isReiterate()
67 ||
68 !$this->letter->getState()->wasStartedSending()
69 )
70 &&
71 !$this->letter->getState()->isFinished()
72 );
73 }
74
80 public function getCode()
81 {
82 return $this->method->getCode();
83 }
84
90 public function defer()
91 {
92 $this->set(new MethodDefered($this->letter));
93 }
94
101 public function time(DateTime $dateTime)
102 {
103 $method = new MethodTime($this->letter);
104 $method->setDateTime($dateTime);
105 $this->set($method);
106 }
107
113 public function now()
114 {
115 $this->time(new DateTime);
116 }
117
123 public function set(iMethod $method)
124 {
125 if ($this->method)
126 {
127 $this->revoke();
128 }
129 $this->method = $method;
130 }
131
137 public function get()
138 {
139 return $this->method;
140 }
141
147 public function apply()
148 {
149 $this->method->apply();
150 }
151
157 public function revoke()
158 {
159 $this->method->revoke();
160 }
161}
static loadMessages($file)
Definition loc.php:64
__construct(Entity\Letter $letter)
Definition method.php:38
time(DateTime $dateTime)
Definition method.php:101