| @@ 304-331 (lines=28) @@ | ||
| 301 | * |
|
| 302 | * @return array |
|
| 303 | */ |
|
| 304 | public function getObjects($filterNamespace = '') { |
|
| 305 | $moduleName = $this->name; |
|
| 306 | $modulePaths = Module::getModulePaths($moduleName); |
|
| 307 | $modulePaths = array_reverse($modulePaths); |
|
| 308 | $scanFn = function ($path, $namespace, &$files = []) use (&$scanFn, $filterNamespace) { |
|
| 309 | if (file_exists($path)) { |
|
| 310 | foreach (scandir($path) as $item) { |
|
| 311 | if (in_array($item, ['..', '.'])) { |
|
| 312 | continue; |
|
| 313 | } |
|
| 314 | $filename = pathinfo($item)['filename']; |
|
| 315 | if (is_dir($path . '/' . $item)) { |
|
| 316 | $scanFn($path . '/' . $item, $namespace . '\\' . $filename, $files); |
|
| 317 | } else { |
|
| 318 | if (!$filterNamespace || strpos($namespace, $filterNamespace) === 0) { |
|
| 319 | $files[$path . '/' . $item] = $namespace . '\\' . $filename; |
|
| 320 | } |
|
| 321 | } |
|
| 322 | } |
|
| 323 | } |
|
| 324 | return $files; |
|
| 325 | }; |
|
| 326 | $files = []; |
|
| 327 | foreach ($modulePaths as $path) { |
|
| 328 | $scanFn($path . '/objects', $moduleName, $files); |
|
| 329 | } |
|
| 330 | return $files; |
|
| 331 | } |
|
| 332 | ||
| 333 | /** |
|
| 334 | * Return module models |
|
| @@ 338-364 (lines=27) @@ | ||
| 335 | * |
|
| 336 | * @return array |
|
| 337 | */ |
|
| 338 | public static function getModels($moduleName, $filterNamespace = '') { |
|
| 339 | $modulePaths = Module::getModulePaths($moduleName); |
|
| 340 | $modulePaths = array_reverse($modulePaths); |
|
| 341 | $scanFn = function ($path, $namespace, &$files = []) use (&$scanFn, $filterNamespace) { |
|
| 342 | if (file_exists($path)) { |
|
| 343 | foreach (scandir($path) as $item) { |
|
| 344 | if (in_array($item, ['..', '.'])) { |
|
| 345 | continue; |
|
| 346 | } |
|
| 347 | $filename = pathinfo($item)['filename']; |
|
| 348 | if (is_dir($path . '/' . $item)) { |
|
| 349 | $scanFn($path . '/' . $item, $namespace . '\\' . $filename, $files); |
|
| 350 | } else { |
|
| 351 | if (!$filterNamespace || strpos($namespace, $filterNamespace) === 0) { |
|
| 352 | $files[$path . '/' . $item] = $namespace . '\\' . $filename; |
|
| 353 | } |
|
| 354 | } |
|
| 355 | } |
|
| 356 | } |
|
| 357 | return $files; |
|
| 358 | }; |
|
| 359 | $files = []; |
|
| 360 | foreach ($modulePaths as $path) { |
|
| 361 | $scanFn($path . '/models', $moduleName, $files); |
|
| 362 | } |
|
| 363 | return $files; |
|
| 364 | } |
|
| 365 | ||
| 366 | /** |
|
| 367 | * Return extensions for type |
|