Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 100ce506ea | |||
| a4c50f975e | |||
| f7630a4c2a | |||
| bf3182660b | |||
| df7b50563f | |||
| b5f20d7d4b | |||
| 244e84772e | |||
| 9529907710 | |||
| 2c31bea602 |
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
namespace PHPSTORM_META {
|
namespace PHPSTORM_META {
|
||||||
|
|
||||||
// Reflect
|
// Reflect
|
||||||
use Http\Context\Context;
|
use Kiri\Message\Context\Context;
|
||||||
use Kiri\Di\Container;
|
use Kiri\Di\Container;
|
||||||
|
|
||||||
override(Container::get(0), map('@'));
|
override(Container::get(0), map('@'));
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace Kiri\Events;
|
namespace Kiri\Events;
|
||||||
|
|
||||||
|
use Kiri;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Kiri;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||||
use Psr\EventDispatcher\StoppableEventInterface;
|
use Psr\EventDispatcher\StoppableEventInterface;
|
||||||
|
|
||||||
@@ -15,10 +17,22 @@ class EventDispatch extends Component implements EventDispatcherInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param EventProvider $eventProvider
|
||||||
|
* @param array $config
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function __construct(public EventProvider $eventProvider, array $config = [])
|
||||||
|
{
|
||||||
|
parent::__construct($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $event
|
* @param object $event
|
||||||
* @return object
|
* @return object
|
||||||
* @throws \ReflectionException
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function dispatch(object $event): object
|
public function dispatch(object $event): object
|
||||||
{
|
{
|
||||||
@@ -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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-3
@@ -10,15 +10,13 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.0",
|
"php": ">=8.0",
|
||||||
"ext-json": "*",
|
|
||||||
"psr/event-dispatcher": "^1.0"
|
"psr/event-dispatcher": "^1.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Kiri\\Events\\": "src/"
|
"Kiri\\Events\\": "./"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"kwn/php-rdkafka-stubs": "^2.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user