1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
counter.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Internals;
4
5use Bitrix\Calendar\Internals\Counter\Provider\GroupInvite;
6use Bitrix\Calendar\Internals\Counter\Provider\OpenEvent;
7use Bitrix\Calendar\Internals\Counter\State\Loader;
8use Bitrix\Calendar\Internals\Counter\State\State;
9use Bitrix\Main;
10use Bitrix\Calendar\Internals\Counter\CounterDictionary;
11use Bitrix\Calendar\Internals\Counter\Provider\Invite;
12use Bitrix\Calendar\Internals\Counter\Provider\Sync;
13
20{
21 private static $instance = [];
22 private int $userId;
23 private State $state;
24
33 public static function getInstance($userId): self
34 {
35 if (!array_key_exists($userId, self::$instance))
36 {
37 self::$instance[$userId] = new self($userId);
38 }
39
40 return self::$instance[$userId];
41 }
42
53 private function __construct($userId)
54 {
55 $this->userId = (int)$userId;
56 $this->state = new State($this->userId, new Loader($this->userId));
57 }
58
64 public function get(string $name, int $entityId = 0): int
65 {
66 return match ($name) {
72 CounterDictionary::COUNTER_INVITES => (new Invite($this->userId, $entityId))->getValue(),
73 CounterDictionary::COUNTER_SYNC_ERRORS => (new Sync($this->userId, $entityId))->getValue(),
74 CounterDictionary::COUNTER_OPEN_EVENTS => (new OpenEvent($this->state, $entityId))->getValue(),
76 CounterDictionary::COUNTER_GROUP_INVITES => (new GroupInvite($this->userId, $entityId))->getValue(),
77 default => 0,
78 };
79 }
80}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstance($userId)
Определения counter.php:33
Определения loader.php:13
$name
Определения menu_edit.php:35
$entityId
Определения payment.php:4