Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/catalog/lib/eventdispatcher/ |
Upload File : |
<?php namespace Bitrix\Catalog\EventDispatcher; use Bitrix\Main\Config\Configuration; use Bitrix\Rest\Event\EventBindInterface; class EventDispatcher { public const PLACEMENT_EXTERNAL_PRODUCT = 'CATALOG_EXTERNAL_PRODUCT'; const SCOPE_CATALOG = 'catalog'; const MODULE_ID = 'catalog'; /** * * Handler of `rest/onRestServiceBuildDescription` event. * * @return array * @throws \ReflectionException */ public static function onRestServiceBuildDescription(): array { return (new EventDispatcher())->dispatch(); } /** * * Collect all PHP module events * * @return \array[][] * @throws \ReflectionException */ public function dispatch(): array { $bindings = []; $classes = $this->collectEntityEventBind(); foreach ($classes as $class) { $reflection = new \ReflectionClass($class); if ( !$reflection->isInterface() && !$reflection->isAbstract() && !$reflection->isTrait()) { if ($reflection->implementsInterface('\\Bitrix\\Rest\\Event\\EventBindInterface')) { $bindings += $this->getBindings($class); } } } return [ self::SCOPE_CATALOG => [ \CRestUtil::EVENTS => $bindings, \CRestUtil::PLACEMENTS => [ self::PLACEMENT_EXTERNAL_PRODUCT => [], ], ] ]; } protected function collectEntityEventBind(): array { $controllersConfig = Configuration::getInstance(self::MODULE_ID); if (!$controllersConfig['controllers'] || !$controllersConfig['controllers']['restIntegration'] || !$controllersConfig['controllers']['restIntegration']['eventBind']) { return []; } return $controllersConfig['controllers']['restIntegration']['eventBind']; } /** * * Get config, handlers and bindings PHP events to REST events * * @param string|EventBindInterface $class * @return array */ public function getBindings(string $class): array { return $class::getHandlers(); } }