Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
counterprovider.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Integration\Tasks
;
4
5
use
Bitrix\Main\Loader
;
6
use
Bitrix\Socialnetwork\Internals\Space\Counter\Dictionary
;
7
use
Bitrix\Socialnetwork\Internals\Space\Counter\ProviderInterface
;
8
use Bitrix\Tasks\Internals\Counter;
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->isTasksModuleAvailable())
19
{
20
return
$result;
21
}
22
23
return
Counter::getInstance($this->userId)->get(Counter\CounterDictionary::COUNTER_MEMBER_TOTAL, $spaceId);
24
}
25
26
public
function
getValue
(
int
$spaceId = 0, array $metrics = []): int
27
{
28
$result = 0;
29
30
if
(!$this->isTasksModuleAvailable())
31
{
32
return
$result;
33
}
34
35
foreach
($metrics as $metric)
36
{
37
switch
($metric)
38
{
39
case
Dictionary::COUNTERS_TASKS_TOTAL:
40
return
$this->
getTotal
($spaceId);
41
//TODO: other cases...
42
}
43
}
44
45
return
$result;
46
}
47
48
public
function
getAvailableMetrics
(): array
49
{
50
return
[
51
Dictionary::COUNTERS_TASKS_TOTAL,
52
];
53
}
54
55
private
function
isTasksModuleAvailable(): bool
56
{
57
return
Loader::includeModule(
'tasks'
);
58
}
59
}
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Socialnetwork\Integration\Tasks\CounterProvider
Definition
counterprovider.php:11
Bitrix\Socialnetwork\Integration\Tasks\CounterProvider\getValue
getValue(int $spaceId=0, array $metrics=[])
Definition
counterprovider.php:26
Bitrix\Socialnetwork\Integration\Tasks\CounterProvider\__construct
__construct(private int $userId)
Definition
counterprovider.php:12
Bitrix\Socialnetwork\Integration\Tasks\CounterProvider\getTotal
getTotal(int $spaceId=0)
Definition
counterprovider.php:14
Bitrix\Socialnetwork\Integration\Tasks\CounterProvider\getAvailableMetrics
getAvailableMetrics()
Definition
counterprovider.php:48
Bitrix\Socialnetwork\Internals\Space\Counter\Dictionary
Definition
dictionary.php:6
Bitrix\Socialnetwork\Internals\Space\Counter\ProviderInterface
Definition
providerinterface.php:6
Bitrix\Socialnetwork\Integration\Tasks
Definition
counterprovider.php:3
modules
socialnetwork
lib
integration
tasks
counterprovider.php
Создано системой
1.10.0