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 ($spaceId === 0)
19 {
20 return $result;
21 }
22
23 $metrics = [
24 CounterDictionary::COUNTER_WORKGROUP_REQUESTS_IN,
25 ];
26
27 foreach ($metrics as $metric)
28 {
29 $result += Counter::getInstance($this->userId)->get($metric, $spaceId)['all'];
30 }
31
32 return $result;
33 }
34
35 public function getValue(int $spaceId = 0, array $metrics = []): int
36 {
37 $result = 0;
38
39 if ($spaceId === 0)
40 {
41 return $result;
42 }
43
44 foreach ($metrics as $metric)
45 {
46 switch ($metric)
47 {
48 case Dictionary::COUNTERS_WORKGROUP_TOTAL:
49 return $this->getTotal($spaceId);
50 case Dictionary::COUNTERS_WORKGROUP_REQUEST_OUT:
51 $result += Counter::getInstance($this->userId)->get(
52 CounterDictionary::COUNTER_WORKGROUP_REQUESTS_OUT,
53 $spaceId)['all'];
54 break;
55 }
56 }
57
58 return $result;
59 }
60
61 public function getAvailableMetrics(): array
62 {
63 return [
64 Dictionary::COUNTERS_WORKGROUP_TOTAL,
65 ];
66 }
67}