Compare commits

..

13 Commits

Author SHA1 Message Date
jay dc414f6277 remove has 2026-08-12 16:12:57 -04:00
jay 5e64879e75 add hasDispatcher method 2026-08-12 14:14:12 -04:00
jay ad754c6806 add getDispatcher method 2026-08-12 13:57:50 -04:00
jay cd1f7ea350 add Behaviour trait 2026-08-12 13:56:42 -04:00
jay 5b76469ba1 require potter/container 2026-08-12 13:56:26 -04:00
jay 26c233295f extend \League\Event\EventDispatcher 2026-08-12 13:56:12 -04:00
jay 72adff3639 re-namespace 2026-08-12 13:51:04 -04:00
jay 1397afb513 re-namespace 2026-08-10 14:09:06 -04:00
jay d102e37841 delete Dispatcher 2026-08-10 14:08:31 -04:00
jay a7eb1bad6b extend \League\Event\EventDispatcher 2026-08-10 13:56:01 -04:00
jay e30003a334 change keyword use 2026-08-10 13:54:56 -04:00
jay e113259766 re-namespace 2026-08-10 13:53:23 -04:00
jay 1f1a23f1a9 implement GenericEvent 2026-08-09 16:39:56 -04:00
4 changed files with 64 additions and 2 deletions
+10 -2
View File
@@ -4,7 +4,7 @@
"license": "MIT", "license": "MIT",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Potter\\": "src/Potter/" "Potter\\Event\\": "src/Potter/Event/"
} }
}, },
"authors": [ "authors": [
@@ -14,5 +14,13 @@
} }
], ],
"minimum-stability": "stable", "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"
}
} }
+25
View File
@@ -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);
}
}
+9
View File
@@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Potter\Event;
final class Dispatcher
extends \League\Event\EventDispatcher
{ }
+20
View File
@@ -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);
}
}