4
4
5
5
namespace Railt \Foundation ;
6
6
7
+ use Psr \EventDispatcher \EventDispatcherInterface ;
7
8
use Railt \Contracts \Http \Middleware \MiddlewareInterface ;
9
+ use Railt \EventDispatcher \EventDispatcher ;
8
10
use Railt \Foundation \Connection \OnDestructor ;
9
11
use Railt \Foundation \Event \Connection \ConnectionClosed ;
10
12
use Railt \Foundation \Event \Connection \ConnectionEstablished ;
18
20
use Railt \SDL \Compiler ;
19
21
use Railt \SDL \CompilerInterface ;
20
22
use Railt \TypeSystem \DictionaryInterface ;
21
- use Symfony \Component \EventDispatcher \EventDispatcher ;
22
- use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
23
23
24
24
final class Application implements ApplicationInterface
25
25
{
@@ -32,6 +32,8 @@ final class Application implements ApplicationInterface
32
32
33
33
private readonly MutablePipelineInterface $ pipeline ;
34
34
35
+ private readonly EventDispatcherInterface $ dispatcher ;
36
+
35
37
/**
36
38
* @param iterable<array-key, MiddlewareInterface>|MutablePipelineInterface $middleware
37
39
* @param iterable<array-key, ExtensionInterface>|Repository $extensions
@@ -41,22 +43,18 @@ public function __construct(
41
43
private readonly CompilerInterface $ compiler = new Compiler (),
42
44
iterable |MutablePipelineInterface $ middleware = [],
43
45
iterable |Repository $ extensions = [],
44
- private readonly EventDispatcherInterface $ dispatcher = new EventDispatcher () ,
46
+ ? EventDispatcherInterface $ dispatcher = null ,
45
47
) {
46
- if (!$ middleware instanceof MutablePipelineInterface) {
47
- $ middleware = new Pipeline ($ middleware );
48
- }
49
-
50
- if (!$ extensions instanceof Repository) {
51
- $ extensions = new Repository ($ extensions );
52
- }
53
-
48
+ $ this ->pipeline = !$ middleware instanceof MutablePipelineInterface
49
+ ? new Pipeline ($ middleware )
50
+ : $ middleware ;
51
+ $ this ->extensions = !$ extensions instanceof Repository
52
+ ? new Repository ($ extensions )
53
+ : $ extensions ;
54
+ $ this ->dispatcher = new EventDispatcher ($ dispatcher );
54
55
/** @psalm-suppress PropertyTypeCoercion */
55
56
$ this ->connections = new \WeakMap ();
56
57
57
- $ this ->extensions = $ extensions ;
58
- $ this ->pipeline = $ middleware ;
59
-
60
58
$ this ->bootDefaultExtensions ();
61
59
}
62
60
0 commit comments