Skip to content

Commit

Permalink
Merge pull request #1042 from spiral/feature/listeners-list
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Dec 25, 2023
1 parent ae03eb4 commit 4eebd04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Bootloader/TokenizerListenerBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ final class TokenizerListenerBootloader extends Bootloader implements
/** @var TokenizationListenerInterface[] */
private array $listeners = [];

/** @var array<class-string<TokenizationListenerInterface>> */
private array $listenerClasses = [];

public function addListener(TokenizationListenerInterface $listener): void
{
$this->listeners[] = $listener;
$this->listenerClasses[] = $listener::class;
}

public function init(AbstractKernel $kernel): void
Expand Down Expand Up @@ -86,6 +90,14 @@ public function initCachedInterfacesLoader(
return $this->makeCachedLoader($factory, $config, CachedInterfacesLoader::class);
}

/**
* @return array<class-string<TokenizationListenerInterface>>
*/
public function getListenerClasses(): array
{
return $this->listenerClasses;
}

/**
* @template T
*
Expand Down
1 change: 1 addition & 0 deletions src/TokenizerListenerRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* It contains all listeners that will be noticed about found classes by a class locator.
* @method getListenerClasses(): array
*/
interface TokenizerListenerRegistryInterface
{
Expand Down

0 comments on commit 4eebd04

Please sign in to comment.