Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
counterprovider.php
1<?php
2
4
9
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 {
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 [
64 ];
65 }
66
67 private function isCalendarModuleAvailable(): bool
68 {
69 return Loader::includeModule('calendar');
70 }
71}