bsidev / bitrix-event-dispatcher
Event dispatcher for Bitrix CMS
v0.9.0
2020-07-08 04:45 UTC
Requires
- php: >=7.2.5
Requires (Dev)
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: ^3.0@dev
This package is auto-updated.
Last update: 2024-11-29 06:10:41 UTC
README
Надстройка над классом Bitrix\Main\EventManager
для 1С-Битрикс.
Позволяет добавлять слушателей и подписчиков событий.
Вдохновлен компонентом symfony/event-dispatcher.
Требования
- PHP
>=7.2.5
- 1С-Битрикс
>=12.0.7
Установка
Composer
composer require bsidev/bitrix-event-dispatcher
Примеры конфигурации
use Bsi\EventDispatcher\EventSubscriberInterface; class MySubscriber implements EventSubscriberInterface { public function onProlog(): void { // Code here... } public function onIblockElementAfterAdd(&$fields): void { // Code here... } public static function getSubscribedEvents(): array { return [ 'main' => [ 'OnProlog' => ['onProlog', 1], ], 'iblock' => [ 'OnAfterIBlockElementAdd' => 'onIblockElementAfterAdd', ], ]; } }
// local/php_interface/init.php $dispatcher = new Bsi\EventDispatcher\EventDispatcher(); $dispatcher->addSubscriber(new MySubscriber());