modify plugin name
This commit is contained in:
+7
-3
@@ -32,11 +32,15 @@ class EventProvider implements ListenerProviderInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $event
|
* @param string $event
|
||||||
* @param callable $handler
|
* @param array|\Closure|string $handler
|
||||||
* @param int $zOrder
|
* @param int $zOrder
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function on(string $event, callable $handler, int $zOrder = 1)
|
public function on(string $event, array|\Closure|string $handler, int $zOrder = 1)
|
||||||
{
|
{
|
||||||
|
if (is_string($handler) && !is_callable($handler, true)) {
|
||||||
|
throw new \Exception('Event handler must is execute function.');
|
||||||
|
}
|
||||||
$this->_listeners[$event][] = new Struct($event, $handler, $zOrder);
|
$this->_listeners[$event][] = new Struct($event, $handler, $zOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +50,7 @@ class EventProvider implements ListenerProviderInterface
|
|||||||
* @param callable $handler
|
* @param callable $handler
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function off(string $event, callable $handler)
|
public function off(string $event, callable $handler): void
|
||||||
{
|
{
|
||||||
$events = $this->_listeners[$event] ?? [];
|
$events = $this->_listeners[$event] ?? [];
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -12,11 +12,11 @@ class Struct
|
|||||||
|
|
||||||
public string $event;
|
public string $event;
|
||||||
|
|
||||||
public array|\Closure $listener;
|
public array|\Closure|string $listener;
|
||||||
|
|
||||||
public int $priority;
|
public int $priority;
|
||||||
|
|
||||||
public function __construct(string $event, callable $listener, int $priority)
|
public function __construct(string $event, array|\Closure|string $listener, int $priority)
|
||||||
{
|
{
|
||||||
$this->event = $event;
|
$this->event = $event;
|
||||||
$this->listener = $listener;
|
$this->listener = $listener;
|
||||||
|
|||||||
Reference in New Issue
Block a user