Compare commits
13 Commits
df91dd6b57
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| dc414f6277 | |||
| 5e64879e75 | |||
| ad754c6806 | |||
| cd1f7ea350 | |||
| 5b76469ba1 | |||
| 26c233295f | |||
| 72adff3639 | |||
| 1397afb513 | |||
| d102e37841 | |||
| a7eb1bad6b | |||
| e30003a334 | |||
| e113259766 | |||
| 1f1a23f1a9 |
+10
-2
@@ -4,7 +4,7 @@
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Potter\\": "src/Potter/"
|
||||
"Potter\\Event\\": "src/Potter/Event/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
@@ -14,5 +14,13 @@
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"require": {}
|
||||
"require": {
|
||||
"league/event": ">=3.0.3",
|
||||
"potter/container": ">=0.0.1",
|
||||
"psr/event-dispatcher": ">=1.0.0",
|
||||
"symfony/event-dispatcher": ">=8.1.2",
|
||||
"symfony/event-dispatcher-contracts": ">=3.7.1",
|
||||
"symfony/deprecation-contracts": ">=3.7.1",
|
||||
"symfony/event-dispatcher": ">=8.1.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter\Event;
|
||||
|
||||
use \Potter\Container;
|
||||
|
||||
trait Behaviour
|
||||
{
|
||||
private static function addDispatcher(Container $container): void
|
||||
{
|
||||
$container->addShared(Dispatcher::class);
|
||||
}
|
||||
|
||||
private static function addEventBehaviour(Container $container): void
|
||||
{
|
||||
self::addDispatcher($container);
|
||||
}
|
||||
|
||||
private static function getDispatcher(Container $container): Dispatcher
|
||||
{
|
||||
return $container->get(Dispatcher::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter\Event;
|
||||
|
||||
final class Dispatcher
|
||||
extends \League\Event\EventDispatcher
|
||||
{ }
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter\Event;
|
||||
|
||||
final class Event
|
||||
extends \Symfony\Component\EventDispatcher\GenericEvent
|
||||
implements \League\Event\HasEventName
|
||||
{
|
||||
public function __construct(mixed $subject = null, array $arguments = []) {
|
||||
parent::__construct($subject, $arguments);
|
||||
}
|
||||
|
||||
public function eventName(): string
|
||||
{
|
||||
return is_string($subject = $this->getSubject()) ?
|
||||
$subject : get_class($this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user