Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
excludeddatecomparemanager.php
1
<?php
2
3
namespace
Bitrix\Calendar\Core\Managers\Compare
;
4
5
use
Bitrix\Calendar\Core\Base\Date
;
6
use
Bitrix\Calendar\Core\Base\Property
;
7
use
Bitrix\Calendar\Core\Event\Properties\ExcludedDatesCollection
;
8
9
class
ExcludedDateCompareManager
implements
CompareManager
10
{
14
protected
$originalCollection
;
18
protected
$currentCollection
;
22
protected
$isEqual
=
true
;
26
protected
$diff
= [];
27
33
public
static
function
createInstance
(?
ExcludedDatesCollection
$originalCollection
, ?
ExcludedDatesCollection
$currentCollection
):
ExcludedDateCompareManager
34
{
35
return
new
self
(
$originalCollection
,
$currentCollection
);
36
}
37
42
public
function
__construct
(?
ExcludedDatesCollection
$originalCollection
, ?
ExcludedDatesCollection
$currentCollection
)
43
{
44
$this->originalCollection =
$originalCollection
??
new
ExcludedDatesCollection
([]);
45
$this->currentCollection =
$currentCollection
??
new
ExcludedDatesCollection
([]);
46
47
$this->
compare
();
48
}
49
53
protected
function
compare
(): void
54
{
55
$this->diff = array_udiff(
56
$this->currentCollection->getCollection(),
57
$this->originalCollection->getCollection(),
58
[$this,
'compareHandler'
]
59
);
60
61
if
(
62
$this->diff
63
|| $this->originalCollection->count() !== $this->currentCollection->count()
64
)
65
{
66
$this->
isEqual
=
false
;
67
}
68
}
69
73
public
function
getDiffCollection
():
ExcludedDatesCollection
74
{
75
return
new
ExcludedDatesCollection
($this->diff);
76
}
77
81
public
function
isEqual
(): bool
82
{
83
return
$this->isEqual
;
84
}
85
89
public
function
hasDiff
(): bool
90
{
91
return
(
bool
)
$this->diff
;
92
}
93
99
private
function
compareHandler(
Date
$current,
Date
$original): int
100
{
101
return
$current->
getTimestamp
() <=> $original->
getTimestamp
();
102
}
103
107
public
function
getDiff
(): array
108
{
109
return
$this->diff
;
110
}
111
}
Bitrix\Calendar\Core\Base\Date
Definition
date.php:10
Bitrix\Calendar\Core\Base\Date\getTimestamp
getTimestamp()
Definition
date.php:129
Bitrix\Calendar\Core\Event\Properties\ExcludedDatesCollection
Definition
excludeddatescollection.php:10
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager
Definition
excludeddatecomparemanager.php:10
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\$diff
$diff
Definition
excludeddatecomparemanager.php:26
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\$isEqual
$isEqual
Definition
excludeddatecomparemanager.php:22
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\hasDiff
hasDiff()
Definition
excludeddatecomparemanager.php:89
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\createInstance
static createInstance(?ExcludedDatesCollection $originalCollection, ?ExcludedDatesCollection $currentCollection)
Definition
excludeddatecomparemanager.php:33
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\isEqual
isEqual()
Definition
excludeddatecomparemanager.php:81
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\__construct
__construct(?ExcludedDatesCollection $originalCollection, ?ExcludedDatesCollection $currentCollection)
Definition
excludeddatecomparemanager.php:42
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\$currentCollection
$currentCollection
Definition
excludeddatecomparemanager.php:18
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\getDiffCollection
getDiffCollection()
Definition
excludeddatecomparemanager.php:73
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\getDiff
getDiff()
Definition
excludeddatecomparemanager.php:107
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\$originalCollection
$originalCollection
Definition
excludeddatecomparemanager.php:14
Bitrix\Calendar\Core\Managers\Compare\ExcludedDateCompareManager\compare
compare()
Definition
excludeddatecomparemanager.php:53
Bitrix\Calendar\Core\Base\Property
Definition
property.php:6
Bitrix\Calendar\Core\Managers\Compare\CompareManager
Definition
comparemanager.php:6
Bitrix\Calendar\Core\Managers\Compare
Definition
comparemanager.php:3
modules
calendar
lib
core
managers
compare
excludeddatecomparemanager.php
Создано системой
1.10.0