Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
counterprovider.php
1<?php
2
4
8
10{
11 public function __construct(private int $userId) { }
12
13 public function isCounted(): bool
14 {
15 return Counter::getInstance($this->userId)->isCounted();
16 }
17
18 public function isEnabled(): bool
19 {
20 return Counter\CounterController::isEnabled($this->userId);
21 }
22
23 public function getTotal(int $spaceId = 0): int
24 {
25 return Counter::getInstance($this->userId)->get(Counter\CounterDictionary::COUNTER_TOTAL, $spaceId);
26 }
27
28 public function getValue(int $spaceId = 0, array $metrics = []): int
29 {
30 $result = 0;
31
32 foreach ($metrics as $metric)
33 {
34 switch ($metric)
35 {
36 case Dictionary::COUNTERS_LIVEFEED_TOTAL:
37 return $this->getTotal($spaceId);
38 //TODO: other cases...
39 }
40 }
41
42 return $result;
43 }
44
45 public function getAvailableMetrics(): array
46 {
47 return [
48 Dictionary::COUNTERS_LIVEFEED_TOTAL,
49 ];
50 }
51}