Skip to content

Commit

Permalink
extract subscriber discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Jun 3, 2017
1 parent b26237d commit 450221c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/EventsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function restoreEventListeners(string $event)
*/
protected function getSubscriberClassName($subscriberClass): string
{
if (is_object($subscriberClass) && in_array(EventSubscriber::class, class_implements($subscriberClass))) {
if ($this->isEventSubscriber($subscriberClass)) {
return get_class($subscriberClass);
}

Expand All @@ -175,6 +175,18 @@ protected function getSubscriberClassName($subscriberClass): string
return $subscriberClass;
}

/**
* Is an event subscriber.
*
* @param $subscriberClass
*
* @return bool
*/
private function isEventSubscriber($subscriberClass): bool
{
return is_object($subscriberClass) && in_array(EventSubscriber::class, class_implements($subscriberClass));
}

/**
* Get registered events.
*
Expand Down
2 changes: 1 addition & 1 deletion src/RepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function getObjectFactory(): callable
if ($this->objectFactory === null) {
$className = $this->getClassName();

$this->objectFactory = function() use ($className) {
$this->objectFactory = function () use ($className) {
return new $className();
};
}
Expand Down

0 comments on commit 450221c

Please sign in to comment.