1 | <?php |
||
10 | class Module |
||
11 | { |
||
12 | use Normalizer, Replacer; |
||
13 | |||
14 | /** |
||
15 | * @var |
||
16 | */ |
||
17 | protected $name; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $options; |
||
23 | |||
24 | /** |
||
25 | * @var Config |
||
26 | */ |
||
27 | protected $config; |
||
28 | |||
29 | /** |
||
30 | * @var Application |
||
31 | */ |
||
32 | protected $laravel; |
||
33 | |||
34 | /** |
||
35 | * Module constructor. |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @param Application $application |
||
39 | * @param array $options |
||
40 | */ |
||
41 | public function __construct( |
||
42 | $name, |
||
43 | Application $application, |
||
44 | array $options = [] |
||
45 | ) { |
||
46 | $this->name = $name; |
||
47 | $this->options = collect($options); |
||
|
|||
48 | $this->laravel = $application; |
||
49 | $this->config = $application['modular.config']; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get module name |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function name() |
||
58 | { |
||
59 | return $this->name; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Get module seeder class name (with namespace) |
||
64 | * |
||
65 | * @param string|null $class |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | public function seederClass($class = null) |
||
70 | { |
||
71 | return $this->fileClass('seeder', $class); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Get module service provider class |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | public function serviceProviderClass() |
||
80 | { |
||
81 | return $this->fileClass('serviceProvider'); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Get file class |
||
86 | * |
||
87 | * @param string $type |
||
88 | * @param string|null $class |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | protected function fileClass($type, $class = null) |
||
93 | { |
||
94 | $filename = $type . 'File'; |
||
95 | $namespace = $type . 'Namespace'; |
||
96 | |||
97 | $class = $class ?: basename($this->config->$filename(), '.php'); |
||
98 | |||
99 | return $this->replace($this->config->modulesNamespace() . '\\' . |
||
100 | $this->name() . '\\' . $this->config->$namespace() . '\\' . |
||
101 | $class, $this); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Get module directory |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function directory() |
||
110 | { |
||
111 | return $this->normalizePath($this->config->directory()) . |
||
112 | DIRECTORY_SEPARATOR . $this->name(); |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * Get module migrations path |
||
117 | * |
||
118 | * @param bool $relative |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function migrationsPath($relative = false) |
||
123 | { |
||
124 | $path = $this->normalizePath($this->config->migrationsPath()); |
||
125 | |||
126 | return $relative ? $path : $this->directory() . DIRECTORY_SEPARATOR . $path; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Verify whether module has service provider |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | public function hasServiceProvider() |
||
138 | |||
139 | /** |
||
140 | * Verifies whether module has factory |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function hasFactory() |
||
145 | { |
||
148 | |||
149 | /** |
||
150 | * Verifies whether module has routes file |
||
151 | * |
||
152 | * @param array $data |
||
153 | * |
||
154 | * @return bool |
||
155 | */ |
||
156 | public function hasRoutes(array $data = []) |
||
162 | |||
163 | /** |
||
164 | * Verifies whether module has seeder file |
||
165 | * |
||
166 | * @return bool |
||
167 | */ |
||
168 | public function hasSeeder() |
||
172 | |||
173 | /** |
||
174 | * Verifies whether module has file of given type either checking config |
||
175 | * and if it's not exist by checking whether file exists |
||
176 | * |
||
177 | * @param string $option |
||
178 | * @param string $pathFunction |
||
179 | * @param string $prefix |
||
180 | * |
||
181 | * @return bool |
||
182 | */ |
||
183 | protected function hasFile($option, $pathFunction, $prefix = '') |
||
190 | |||
191 | /** |
||
192 | * Get controller namespace for routing |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | public function routingControllerNamespace() |
||
201 | |||
202 | /** |
||
203 | * Get module routes file (with path) |
||
204 | * |
||
205 | * @param string $prefix |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function routesFilePath($prefix) |
||
213 | |||
214 | /** |
||
215 | * Get route prefix |
||
216 | * |
||
217 | * @param array $data |
||
218 | * |
||
219 | * @return string |
||
220 | */ |
||
221 | public function routePrefix(array $data) |
||
225 | |||
226 | /** |
||
227 | * Get module factory file path |
||
228 | * |
||
229 | * @return string |
||
230 | */ |
||
231 | public function factoryFilePath() |
||
235 | |||
236 | /** |
||
237 | * Get module factory file path |
||
238 | * |
||
239 | * @return string |
||
240 | */ |
||
241 | public function seederFilePath() |
||
245 | |||
246 | /** |
||
247 | * Get module service provider file path |
||
248 | * |
||
249 | * @return string |
||
250 | */ |
||
251 | public function serviceProviderFilePath() |
||
255 | |||
256 | /** |
||
257 | * Get path |
||
258 | * |
||
259 | * @param string $configMethod |
||
260 | * @param string $prefix |
||
261 | * |
||
262 | * @return string |
||
263 | */ |
||
264 | protected function getPath($configMethod, $prefix = '') |
||
269 | |||
270 | /** |
||
271 | * Verifies whether given module is active |
||
272 | * |
||
273 | * @return bool |
||
274 | */ |
||
275 | public function active() |
||
279 | } |
||
280 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..