diff --git a/composer.json b/composer.json
index ba72716d..e6e20989 100644
--- a/composer.json
+++ b/composer.json
@@ -53,6 +53,7 @@
"require-dev": {
"devster/ubench": "^2.0",
"doctrine/data-fixtures": "^1.3",
+ "eaglewu/swoole-ide-helper": "dev-master",
"filp/whoops": "^2.0",
"infection/infection": "^0.12.2",
"phpstan/phpstan": "^0.11.2",
@@ -70,10 +71,12 @@
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
"Shlinkio\\Shlink\\Rest\\": "module/Rest/src",
"Shlinkio\\Shlink\\Core\\": "module/Core/src",
- "Shlinkio\\Shlink\\Common\\": "module/Common/src"
+ "Shlinkio\\Shlink\\Common\\": "module/Common/src",
+ "Shlinkio\\Shlink\\EventDispatcher\\": "module/EventDispatcher/src"
},
"files": [
- "module/Common/functions/functions.php"
+ "module/Common/functions/functions.php",
+ "module/EventDispatcher/functions/functions.php"
]
},
"autoload-dev": {
@@ -88,7 +91,8 @@
"ShlinkioTest\\Shlink\\Common\\": [
"module/Common/test",
"module/Common/test-db"
- ]
+ ],
+ "ShlinkioTest\\Shlink\\EventDispatcher\\": "module/EventDispatcher/test"
}
},
"scripts": {
diff --git a/config/autoload/event_dispatcher.global.php b/config/autoload/event_dispatcher.global.php
deleted file mode 100644
index 53964152..00000000
--- a/config/autoload/event_dispatcher.global.php
+++ /dev/null
@@ -1,20 +0,0 @@
- [
- 'factories' => [
- Psr\ListenerProviderInterface::class => Common\EventDispatcher\ListenerProviderFactory::class,
- ],
- 'aliases' => [
- Psr\EventDispatcherInterface::class => Phly\EventDispatcher::class,
- ],
- ],
-
-];
diff --git a/config/config.php b/config/config.php
index e10d3c1e..f09bb9f6 100644
--- a/config/config.php
+++ b/config/config.php
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace Shlinkio\Shlink;
use Acelaya\ExpressiveErrorHandler;
-use Phly\EventDispatcher;
use Zend\ConfigAggregator;
use Zend\Expressive;
+
use function Shlinkio\Shlink\Common\env;
return (new ConfigAggregator\ConfigAggregator([
@@ -16,11 +16,11 @@ return (new ConfigAggregator\ConfigAggregator([
Expressive\Plates\ConfigProvider::class,
Expressive\Swoole\ConfigProvider::class,
ExpressiveErrorHandler\ConfigProvider::class,
- EventDispatcher\ConfigProvider::class,
Common\ConfigProvider::class,
Core\ConfigProvider::class,
CLI\ConfigProvider::class,
Rest\ConfigProvider::class,
+ EventDispatcher\ConfigProvider::class,
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
new ConfigAggregator\ZendConfigProvider('config/params/{generated_config.php,*.config.{php,json}}'),
env('APP_ENV') === 'test'
diff --git a/module/Common/functions/functions.php b/module/Common/functions/functions.php
index 17856af2..485df607 100644
--- a/module/Common/functions/functions.php
+++ b/module/Common/functions/functions.php
@@ -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);
-}
diff --git a/module/EventDispatcher/config/event_dispatcher.config.php b/module/EventDispatcher/config/event_dispatcher.config.php
new file mode 100644
index 00000000..9930d9e3
--- /dev/null
+++ b/module/EventDispatcher/config/event_dispatcher.config.php
@@ -0,0 +1,27 @@
+ [
+ 'regular' => [],
+ 'async' => [],
+ ],
+
+ 'dependencies' => [
+ 'factories' => [
+ Phly\EventDispatcher::class => Phly\EventDispatcherFactory::class,
+ Psr\ListenerProviderInterface::class => Listener\ListenerProviderFactory::class,
+ ],
+ 'aliases' => [
+ Psr\EventDispatcherInterface::class => Phly\EventDispatcher::class,
+ ],
+ ],
+
+];
diff --git a/module/Common/config/task_runner.config.php b/module/EventDispatcher/config/task_runner.config.php
similarity index 56%
rename from module/Common/config/task_runner.config.php
rename to module/EventDispatcher/config/task_runner.config.php
index 8f0e688e..a0a23db5 100644
--- a/module/Common/config/task_runner.config.php
+++ b/module/EventDispatcher/config/task_runner.config.php
@@ -1,7 +1,7 @@
[
'factories' => [
- EventDispatcher\TaskRunner::class => EventDispatcher\TaskRunnerFactory::class,
+ Async\TaskRunner::class => Async\TaskRunnerFactory::class,
],
'delegators' => [
HttpServer::class => [
- EventDispatcher\TaskRunnerDelegator::class,
+ Async\TaskRunnerDelegator::class,
],
],
],
diff --git a/module/EventDispatcher/functions/functions.php b/module/EventDispatcher/functions/functions.php
new file mode 100644
index 00000000..a1c93231
--- /dev/null
+++ b/module/EventDispatcher/functions/functions.php
@@ -0,0 +1,11 @@
+
./module/CLI/test
-
- ./module/Installer/test
+
+ ./module/EventDispatcher/test