Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
CacheTrait.php
1<?php
2
4
6{
7 private static ?SwitcherCollection $switchers = null;
8
9 public static function get(int $userId, ?int $spaceId, string $code): SwitcherInterface
10 {
11 static::init();
12
14 $switcher = new static($userId, $spaceId, $code);
15 if (static::$switchers->has($switcher))
16 {
17 return $switcher;
18 }
19
20 static::$switchers->add($switcher);
21 return $switcher;
22 }
23
24 private static function init(): void
25 {
26 if (is_null(static::$switchers))
27 {
28 static::$switchers = new SwitcherCollection();
29 }
30 }
31
32 public function invalidate(): void
33 {
34 $this->isInitialized = false;
35 }
36}