Add method to retrieve event handlers by command
This commit is contained in:
parent
1cf82401c3
commit
53824b7126
1 changed files with 21 additions and 0 deletions
|
@ -289,6 +289,27 @@
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves an array of event handlers that correspond to the specified command.
|
||||||
|
*
|
||||||
|
* @param string $command The command to filter the event handlers by.
|
||||||
|
* @return array The array of event handlers that match the specified command.
|
||||||
|
*/
|
||||||
|
public function getEventHandlersByCommand(string $command): array
|
||||||
|
{
|
||||||
|
$results = [];
|
||||||
|
/** @var UpdateEvent $eventHandler */
|
||||||
|
foreach($this->eventHandlers as $eventHandler)
|
||||||
|
{
|
||||||
|
if(strtolower($eventHandler::getCommand()) === strtolower($command))
|
||||||
|
{
|
||||||
|
$results[] = $eventHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all event handlers.
|
* Removes all event handlers.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue