Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
eventdispatcher.php
1
<?php
2
3
namespace
Bitrix\Catalog\EventDispatcher
;
4
5
use
Bitrix\Main\Config\Configuration
;
6
use
Bitrix\Rest\Event\EventBindInterface
;
7
8
class
EventDispatcher
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
}
Bitrix\Catalog\EventDispatcher\EventDispatcher
Definition
eventdispatcher.php:9
Bitrix\Catalog\EventDispatcher\EventDispatcher\onRestServiceBuildDescription
static onRestServiceBuildDescription()
Definition
eventdispatcher.php:20
Bitrix\Catalog\EventDispatcher\EventDispatcher\collectEntityEventBind
collectEntityEventBind()
Definition
eventdispatcher.php:58
Bitrix\Catalog\EventDispatcher\EventDispatcher\getBindings
getBindings(string $class)
Definition
eventdispatcher.php:77
Bitrix\Catalog\EventDispatcher\EventDispatcher\MODULE_ID
const MODULE_ID
Definition
eventdispatcher.php:11
Bitrix\Catalog\EventDispatcher\EventDispatcher\dispatch
dispatch()
Definition
eventdispatcher.php:32
Bitrix\Catalog\EventDispatcher\EventDispatcher\SCOPE_CATALOG
const SCOPE_CATALOG
Definition
eventdispatcher.php:10
Bitrix\Main\Config\Configuration
Definition
configuration.php:7
Bitrix\Main\Config\Configuration\getInstance
static getInstance($moduleId=null)
Definition
configuration.php:48
Bitrix\Rest\Event\EventBindInterface
Definition
eventbindinterface.php:12
Bitrix\Catalog\EventDispatcher
Definition
eventdispatcher.php:3
modules
catalog
lib
eventdispatcher
eventdispatcher.php
Создано системой
1.10.0