Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf3182660b | |||
| df7b50563f |
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
namespace Kiri\Events;
|
namespace Kiri\Events;
|
||||||
|
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Kiri;
|
use Kiri;
|
||||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||||
use Psr\EventDispatcher\StoppableEventInterface;
|
use Psr\EventDispatcher\StoppableEventInterface;
|
||||||
|
|
||||||
|
|||||||
@@ -41,4 +41,19 @@ class EventProvider implements ListenerProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $event
|
||||||
|
* @param callable $handler
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function off(string $event, callable $handler)
|
||||||
|
{
|
||||||
|
$events = $this->_listeners[$event] ?? [];
|
||||||
|
|
||||||
|
$this->_listeners[$event] = array_filter($events, function ($value) use ($handler) {
|
||||||
|
return $value->listener !== $handler;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user