1 | <?php |
||
16 | abstract class AbstractModule |
||
17 | { |
||
18 | /** |
||
19 | * @var Matcher |
||
20 | */ |
||
21 | protected $matcher; |
||
22 | |||
23 | /** |
||
24 | * @var AbstractModule |
||
25 | */ |
||
26 | protected $lastModule; |
||
27 | |||
28 | /** |
||
29 | * @var Container |
||
30 | */ |
||
31 | private $container; |
||
32 | |||
33 | 48 | public function __construct( |
|
34 | AbstractModule $module = null |
||
35 | ) { |
||
36 | 48 | $this->lastModule = $module; |
|
37 | 48 | $this->activate(); |
|
38 | 47 | if ($module) { |
|
39 | 5 | $this->container->merge($module->getContainer()); |
|
40 | } |
||
41 | 47 | } |
|
42 | |||
43 | /** |
||
44 | * Install module |
||
45 | */ |
||
46 | 41 | public function install(AbstractModule $module) |
|
50 | |||
51 | /** |
||
52 | * Override module |
||
53 | */ |
||
54 | 1 | public function override(AbstractModule $module) |
|
59 | |||
60 | /** |
||
61 | * Return container |
||
62 | * |
||
63 | * @return Container |
||
64 | */ |
||
65 | 49 | public function getContainer() : Container |
|
73 | |||
74 | /** |
||
75 | * Bind interceptor |
||
76 | * |
||
77 | * @param AbstractMatcher $classMatcher |
||
78 | * @param AbstractMatcher $methodMatcher |
||
79 | * @param array $interceptors |
||
80 | */ |
||
81 | 40 | public function bindInterceptor(AbstractMatcher $classMatcher, AbstractMatcher $methodMatcher, array $interceptors) |
|
89 | |||
90 | /** |
||
91 | * Bind interceptor early |
||
92 | * |
||
93 | * @param AbstractMatcher $classMatcher |
||
94 | * @param AbstractMatcher $methodMatcher |
||
95 | * @param array $interceptors |
||
96 | */ |
||
97 | 1 | public function bindPriorityInterceptor(AbstractMatcher $classMatcher, AbstractMatcher $methodMatcher, array $interceptors) |
|
105 | |||
106 | /** |
||
107 | * Rename binding name |
||
108 | * |
||
109 | * @param string $interface Interface |
||
110 | * @param string $newName New binding name |
||
111 | * @param string $sourceName Original binding name |
||
112 | * @param string $targetInterface Original interface |
||
113 | */ |
||
114 | 1 | public function rename(string $interface, string $newName, string $sourceName = Name::ANY, string $targetInterface = '') |
|
119 | |||
120 | /** |
||
121 | * Configure binding |
||
122 | */ |
||
123 | abstract protected function configure(); |
||
124 | |||
125 | /** |
||
126 | * Bind interface |
||
127 | */ |
||
128 | 48 | protected function bind(string $interface = '') : Bind |
|
134 | |||
135 | /** |
||
136 | * Activate bindings |
||
137 | */ |
||
138 | 49 | private function activate() |
|
144 | } |
||
145 |