Skip to content

Commit 7a3ba76

Browse files
committed
Stuff
1 parent 16a8cf5 commit 7a3ba76

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Services/SymfonyEvents/CustomEvents.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Prokl\BitrixOrdinaryToolsBundle\Services\SymfonyEvents;
44

5+
use Iterator;
56
use Prokl\BitrixOrdinaryToolsBundle\Services\SymfonyEvents\Interfaces\BitrixComponentEventHandlerInterface;
67
use stdClass;
78
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -13,20 +14,20 @@
1314
class CustomEvents
1415
{
1516
/**
16-
* @var array $listenersCollection Коллекция слушателей событий.
17+
* @var BitrixComponentEventHandlerInterface[] $listenersCollection Слушатели событий.
1718
*/
18-
private $listenersCollection;
19+
private $listenersCollection = [];
1920

2021
/**
21-
* @var EventDispatcherInterface $dispatcher
22+
* @var EventDispatcherInterface $dispatcher Event dispatcher.
2223
*/
2324
private $dispatcher;
2425

2526
/**
2627
* Events constructor.
2728
*
28-
* @param EventDispatcherInterface $dispatcher
29-
* @param ... $eventsHandlerBag
29+
* @param EventDispatcherInterface $dispatcher Event dispatcher.
30+
* @param mixed ...$eventsHandlerBag Сервисы, отмеченные тэгом bitrix.component.event.
3031
*/
3132
public function __construct(
3233
EventDispatcherInterface $dispatcher,
@@ -41,7 +42,12 @@ public function __construct(
4142
$handlers[] = $array;
4243
}
4344

44-
$this->listenersCollection = $handlers;
45+
46+
$handlers = array_filter($handlers);
47+
48+
if (count($handlers) > 0) {
49+
$this->listenersCollection = $handlers;
50+
}
4551

4652
$this->dispatcher = $dispatcher;
4753
}

0 commit comments

Comments
 (0)