Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventdispatcher.php
1<?php
2
4
7
9{
10 const SCOPE_CATALOG = 'catalog';
11 const MODULE_ID = 'catalog';
12
20 public static function onRestServiceBuildDescription(): array
21 {
22 return (new EventDispatcher())->dispatch();
23 }
24
32 public function dispatch(): array
33 {
34 $bindings = [];
35 $classes = $this->collectEntityEventBind();
36
37 foreach ($classes as $class)
38 {
39 $reflection = new \ReflectionClass($class);
40 if (
41 !$reflection->isInterface()
42 && !$reflection->isAbstract()
43 && !$reflection->isTrait())
44 {
45 if ($reflection->implementsInterface('\\Bitrix\\Rest\\Event\\EventBindInterface'))
46 {
47 $bindings += $this->getBindings($class);
48 }
49 }
50 }
51 return [
52 self::SCOPE_CATALOG => [
53 \CRestUtil::EVENTS => $bindings
54 ]
55 ];
56 }
57
58 protected function collectEntityEventBind(): array
59 {
60 $controllersConfig = Configuration::getInstance(self::MODULE_ID);
61
62 if (!$controllersConfig['controllers'] || !$controllersConfig['controllers']['restIntegration'] || !$controllersConfig['controllers']['restIntegration']['eventBind'])
63 {
64 return [];
65 }
66
67 return $controllersConfig['controllers']['restIntegration']['eventBind'];
68 }
69
77 public function getBindings(string $class): array
78 {
79 return $class::getHandlers();
80 }
81}
static getInstance($moduleId=null)