Merge pull request #1501 from Reasno/framework

feat: bridge symfony events to hyperf event dispatcher.
This commit is contained in:
谷溪 2020-04-06 09:58:16 +08:00 committed by GitHub
commit b28e5435e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 101 additions and 0 deletions

View File

@ -1,5 +1,9 @@
# v1.1.24 - TBD
## Added
- [#1501](https://github.com/hyperf/hyperf/pull/1501) Bridged Symfony command events to Hyperf event dispatcher.
## Fixed
- [#1494](https://github.com/hyperf/hyperf/pull/1494) Ignore `@mixin` annotation in redis component

View File

@ -40,6 +40,11 @@ class ApplicationFactory
$commands = array_unique(array_merge($commands, $annotationCommands));
$application = new Application();
if (isset($eventDispatcher)) {
$application->setDispatcher(new SymfonyEventDispatcher($eventDispatcher));
}
foreach ($commands as $command) {
$application->add($container->get($command));
}

View File

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Framework\Exception;
class NotImplementedException extends \RuntimeException
{
}

View File

@ -0,0 +1,75 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Framework;
use Hyperf\Framework\Exception\NotImplementedException;
use Psr\EventDispatcher\EventDispatcherInterface as PsrDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface as SymfonyDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class SymfonyEventDispatcher.
* @internal
*/
class SymfonyEventDispatcher implements SymfonyDispatcherInterface
{
/**
* @var PsrDispatcherInterface
*/
private $psrDispatcher;
public function __construct(PsrDispatcherInterface $psrDispatcher)
{
$this->psrDispatcher = $psrDispatcher;
}
public function addListener($eventName, $listener, $priority = 0)
{
throw new NotImplementedException();
}
public function addSubscriber(EventSubscriberInterface $subscriber)
{
throw new NotImplementedException();
}
public function removeListener($eventName, $listener)
{
throw new NotImplementedException();
}
public function removeSubscriber(EventSubscriberInterface $subscriber)
{
throw new NotImplementedException();
}
public function getListeners($eventName = null)
{
throw new NotImplementedException();
}
public function dispatch($event)
{
$this->psrDispatcher->dispatch($event);
}
public function getListenerPriority($eventName, $listener)
{
throw new NotImplementedException();
}
public function hasListeners($eventName = null)
{
throw new NotImplementedException();
}
}