Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
registry.php
1<?php
2
4
11use Bitrix\Calendar\Core\Base\SingletonTrait;
13
15{
16 use SingletonTrait;
17
18 private array $rules = [];
19
20 protected function __construct()
21 {
23 $this->registerRule(new PushDelayedRule());
27 }
28
34 public function registerRule(RouteRule $rule): self
35 {
36 $this->rules[] = $rule;
37
38 return $this;
39 }
40
48 public function registerRuleClass(string $className): self
49 {
50 if (class_exists($className))
51 {
52 $rule = new $className();
53 if ($rule instanceof RouteRule)
54 {
55 $this->registerRule($rule);
56 }
57 else
58 {
59 throw InvalidRuleException::classIsNotRule();
60 }
61 }
62 else
63 {
64 throw InvalidRuleException::classIsInvalid(404);
65 }
66
67 return $this;
68 }
69
73 public function getRules(): array
74 {
75 return $this->rules;
76 }
77}