Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
counterprovider.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Integration\Calendar
;
4
5
use
Bitrix\Calendar\Ui\CountersManager
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Socialnetwork\Internals\Space\Counter\Dictionary
;
8
use
Bitrix\Socialnetwork\Internals\Space\Counter\ProviderInterface
;
9
10
class
CounterProvider
implements
ProviderInterface
11
{
12
public
function
__construct
(
private
int
$userId) { }
13
14
public
function
getTotal
(
int
$spaceId = 0): int
15
{
16
$result = 0;
17
18
if
(!$this->isCalendarModuleAvailable())
19
{
20
return
$result;
21
}
22
23
if
($spaceId !== 0)
24
{
25
return
$result;
26
}
27
28
$counters = CountersManager::getValues($this->userId);
29
30
if
(isset($counters[
'invitation'
][
'value'
]))
31
{
32
return
(
int
)$counters[
'invitation'
][
'value'
];
33
}
34
35
return
$result;
36
}
37
38
public
function
getValue
(
int
$spaceId = 0, array $metrics = []): int
39
{
40
$result = 0;
41
42
if
(!$this->isCalendarModuleAvailable())
43
{
44
return
$result;
45
}
46
47
foreach
($metrics as $metric)
48
{
49
switch
($metric)
50
{
51
case
Dictionary::COUNTERS_CALENDAR_TOTAL
:
52
return
$this->
getTotal
($spaceId);
53
//TODO: other cases ...
54
}
55
}
56
57
return
$result;
58
}
59
60
public
function
getAvailableMetrics
(): array
61
{
62
return
[
63
Dictionary::COUNTERS_CALENDAR_TOTAL
,
64
];
65
}
66
67
private
function
isCalendarModuleAvailable(): bool
68
{
69
return
Loader::includeModule(
'calendar'
);
70
}
71
}
Bitrix\Calendar\Ui\CountersManager
Definition
countersmanager.php:6
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Socialnetwork\Integration\Calendar\CounterProvider
Definition
counterprovider.php:11
Bitrix\Socialnetwork\Integration\Calendar\CounterProvider\getValue
getValue(int $spaceId=0, array $metrics=[])
Definition
counterprovider.php:38
Bitrix\Socialnetwork\Integration\Calendar\CounterProvider\__construct
__construct(private int $userId)
Definition
counterprovider.php:12
Bitrix\Socialnetwork\Integration\Calendar\CounterProvider\getTotal
getTotal(int $spaceId=0)
Definition
counterprovider.php:14
Bitrix\Socialnetwork\Integration\Calendar\CounterProvider\getAvailableMetrics
getAvailableMetrics()
Definition
counterprovider.php:60
Bitrix\Socialnetwork\Internals\Space\Counter\Dictionary
Definition
dictionary.php:6
Bitrix\Socialnetwork\Internals\Space\Counter\Dictionary\COUNTERS_CALENDAR_TOTAL
const COUNTERS_CALENDAR_TOTAL
Definition
dictionary.php:11
Bitrix\Socialnetwork\Internals\Space\Counter\ProviderInterface
Definition
providerinterface.php:6
Bitrix\Socialnetwork\Integration\Calendar
Definition
apiversion.php:8
modules
socialnetwork
lib
integration
calendar
counterprovider.php
Создано системой
1.10.0