Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
duration.php
1
<?php
8
namespace
Bitrix\Sender\Dispatch
;
9
10
use
Bitrix\Main\Localization\Loc
;
11
12
use
Bitrix\Main\Type\DateTime
;
13
use
Bitrix\Sender\Entity
;
14
15
Loc::loadMessages
(__FILE__);
16
21
class
Duration
22
{
24
private
$letter;
25
27
private
$durationCountBased;
28
30
private
$durationDateBased;
31
37
public
function
__construct
(
Entity
\
Letter
$letter)
38
{
39
$this->letter = $letter;
40
$this->durationCountBased =
new
DurationCountBased
($letter->getMessage());
41
$this->durationDateBased =
new
DurationDateBased
($letter);
42
}
43
49
public
function
getDate
()
50
{
51
$date =
new
DateTime
;
52
$date->
add
($this->
getInterval
() .
' seconds'
);
53
return
$date;
54
}
55
61
protected
function
getCount
()
62
{
63
return
$this->letter->getCounter()->getUnsent();
64
}
65
71
public
function
getInterval
()
72
{
73
$count = $this->
getCount
();
74
$interval = $this->durationCountBased->getInterval($count);
75
if
(!$interval)
76
{
77
$interval = $this->durationDateBased->getInterval($count);
78
}
79
80
return
$interval;
81
}
82
88
public
function
getFormatted
()
89
{
90
return
$this->
format
($this->
getDate
());
91
}
92
98
public
static
function
getFormattedMinimalInterval
()
99
{
100
return
Loc::getMessage
(
'SENDER_DISPATCH_DURATION_LESS_HOUR'
);
101
}
102
108
public
static
function
getFormattedMaximalInterval
()
109
{
110
return
Loc::getMessage
(
'SENDER_DISPATCH_DURATION_MORE_3_DAYS'
);
111
}
112
118
public
static
function
getMinimalInterval
()
119
{
120
return
3600;
121
}
122
128
public
static
function
getMaximalInterval
()
129
{
130
return
3600 * 24 * 3;
131
}
132
138
public
static
function
getWarnInterval
()
139
{
140
return
self::getMinimalInterval
() * 10;
141
}
142
148
public
function
getFormattedInterval
()
149
{
150
if
($this->
getInterval
() < self::getMinimalInterval())
151
{
152
return
self::getFormattedMinimalInterval
();
153
}
154
elseif ($this->
getInterval
() > self::getMaximalInterval())
155
{
156
return
self::getFormattedMaximalInterval
();
157
}
158
else
159
{
160
$formatted = \FormatDate(
'Hdiff'
, $this->
getDate
());
161
if
(mb_substr($formatted, 0, 1) ===
'-'
)
162
{
163
$formatted = mb_substr($formatted, 1);
164
}
165
166
return
$formatted;
167
}
168
}
169
176
public
function
format
(
DateTime
$dateTime =
null
)
177
{
178
if
(!$dateTime)
179
{
180
return
''
;
181
}
182
183
return \FormatDate(
'd F, H:i'
, $dateTime);
184
}
185
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\Type\Date\add
add($interval)
Definition
date.php:145
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Sender\Dispatch\DurationCountBased
Definition
durationcountbased.php:22
Bitrix\Sender\Dispatch\DurationDateBased
Definition
durationdatebased.php:22
Bitrix\Sender\Dispatch\Duration
Definition
duration.php:22
Bitrix\Sender\Dispatch\Duration\getFormattedInterval
getFormattedInterval()
Definition
duration.php:148
Bitrix\Sender\Dispatch\Duration\getFormattedMaximalInterval
static getFormattedMaximalInterval()
Definition
duration.php:108
Bitrix\Sender\Dispatch\Duration\getCount
getCount()
Definition
duration.php:61
Bitrix\Sender\Dispatch\Duration\getDate
getDate()
Definition
duration.php:49
Bitrix\Sender\Dispatch\Duration\getInterval
getInterval()
Definition
duration.php:71
Bitrix\Sender\Dispatch\Duration\__construct
__construct(Entity\Letter $letter)
Definition
duration.php:37
Bitrix\Sender\Dispatch\Duration\getMaximalInterval
static getMaximalInterval()
Definition
duration.php:128
Bitrix\Sender\Dispatch\Duration\getFormattedMinimalInterval
static getFormattedMinimalInterval()
Definition
duration.php:98
Bitrix\Sender\Dispatch\Duration\getMinimalInterval
static getMinimalInterval()
Definition
duration.php:118
Bitrix\Sender\Dispatch\Duration\getWarnInterval
static getWarnInterval()
Definition
duration.php:138
Bitrix\Sender\Dispatch\Duration\format
format(DateTime $dateTime=null)
Definition
duration.php:176
Bitrix\Sender\Dispatch\Duration\getFormatted
getFormatted()
Definition
duration.php:88
Bitrix\Sender\Entity\Letter
Definition
letter.php:34
Bitrix\Sender\Dispatch
Definition
duration.php:8
Bitrix\Sender\Entity
Definition
ad.php:8
modules
sender
lib
dispatch
duration.php
Создано системой
1.10.0