mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Moved all event-dispatching stuff to its own module
This commit is contained in:
@@ -3,8 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common;
|
||||
|
||||
use Swoole\Http\Server as HttpServer;
|
||||
|
||||
use const JSON_ERROR_NONE;
|
||||
|
||||
use function getenv;
|
||||
@@ -61,8 +59,3 @@ function json_decode(string $json, int $depth = 512, int $options = 0): array
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function asyncListener(HttpServer $server, string $regularListenerName): EventDispatcher\AsyncEventListener
|
||||
{
|
||||
return new EventDispatcher\AsyncEventListener($server, $regularListenerName);
|
||||
}
|
||||
|
||||
27
module/EventDispatcher/config/event_dispatcher.config.php
Normal file
27
module/EventDispatcher/config/event_dispatcher.config.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\EventDispatcher;
|
||||
|
||||
use Phly\EventDispatcher as Phly;
|
||||
use Psr\EventDispatcher as Psr;
|
||||
use Shlinkio\Shlink\Common;
|
||||
|
||||
return [
|
||||
|
||||
'events' => [
|
||||
'regular' => [],
|
||||
'async' => [],
|
||||
],
|
||||
|
||||
'dependencies' => [
|
||||
'factories' => [
|
||||
Phly\EventDispatcher::class => Phly\EventDispatcherFactory::class,
|
||||
Psr\ListenerProviderInterface::class => Listener\ListenerProviderFactory::class,
|
||||
],
|
||||
'aliases' => [
|
||||
Psr\EventDispatcherInterface::class => Phly\EventDispatcher::class,
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common;
|
||||
namespace Shlinkio\Shlink\EventDispatcher;
|
||||
|
||||
use Swoole\Http\Server as HttpServer;
|
||||
|
||||
@@ -9,11 +9,11 @@ return [
|
||||
|
||||
'dependencies' => [
|
||||
'factories' => [
|
||||
EventDispatcher\TaskRunner::class => EventDispatcher\TaskRunnerFactory::class,
|
||||
Async\TaskRunner::class => Async\TaskRunnerFactory::class,
|
||||
],
|
||||
'delegators' => [
|
||||
HttpServer::class => [
|
||||
EventDispatcher\TaskRunnerDelegator::class,
|
||||
Async\TaskRunnerDelegator::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
11
module/EventDispatcher/functions/functions.php
Normal file
11
module/EventDispatcher/functions/functions.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\EventDispatcher;
|
||||
|
||||
use Swoole\Http\Server as HttpServer;
|
||||
|
||||
function asyncListener(HttpServer $server, string $regularListenerName): Listener\AsyncEventListener
|
||||
{
|
||||
return new Listener\AsyncEventListener($server, $regularListenerName);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\EventDispatcher;
|
||||
namespace Shlinkio\Shlink\EventDispatcher\Async;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\EventDispatcher;
|
||||
namespace Shlinkio\Shlink\EventDispatcher\Async;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\EventDispatcher;
|
||||
namespace Shlinkio\Shlink\EventDispatcher\Async;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\EventDispatcher;
|
||||
namespace Shlinkio\Shlink\EventDispatcher\Async;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
15
module/EventDispatcher/src/ConfigProvider.php
Normal file
15
module/EventDispatcher/src/ConfigProvider.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\EventDispatcher;
|
||||
|
||||
use Zend\Config\Factory;
|
||||
use Zend\Stdlib\Glob;
|
||||
|
||||
class ConfigProvider
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
return Factory::fromFiles(Glob::glob(__DIR__ . '/../config/{,*.}config.php', Glob::GLOB_BRACE));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\EventDispatcher;
|
||||
namespace Shlinkio\Shlink\EventDispatcher\Listener;
|
||||
|
||||
use Shlinkio\Shlink\EventDispatcher\Async\Task;
|
||||
use Swoole\Http\Server as HttpServer;
|
||||
|
||||
class AsyncEventListener
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Common\EventDispatcher;
|
||||
namespace Shlinkio\Shlink\EventDispatcher\Listener;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Phly\EventDispatcher\ListenerProvider\AttachableListenerProvider;
|
||||
@@ -9,7 +9,7 @@ use Swoole\Http\Server as HttpServer;
|
||||
use Zend\ServiceManager\Factory\FactoryInterface;
|
||||
|
||||
use function Phly\EventDispatcher\lazyListener;
|
||||
use function Shlinkio\Shlink\Common\asyncListener;
|
||||
use function Shlinkio\Shlink\EventDispatcher\asyncListener;
|
||||
|
||||
class ListenerProviderFactory implements FactoryInterface
|
||||
{
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Common\EventDispatcher;
|
||||
namespace ShlinkioTest\Shlink\EventDispatcher\Listener;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Phly\EventDispatcher\ListenerProvider\AttachableListenerProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionObject;
|
||||
use Shlinkio\Shlink\Common\EventDispatcher\ListenerProviderFactory;
|
||||
use Shlinkio\Shlink\EventDispatcher\Listener\ListenerProviderFactory;
|
||||
|
||||
use function Phly\EventDispatcher\lazyListener;
|
||||
|
||||
Reference in New Issue
Block a user