1 | <?php |
||
15 | class ComponentServiceProvider extends ServiceProvider |
||
16 | { |
||
17 | 48 | public function boot() |
|
25 | |||
26 | 48 | public function register() |
|
30 | |||
31 | protected function registerInstanceComponent(ComponentInterface $component) |
||
35 | |||
36 | 48 | protected function bindRouteModel() |
|
58 | |||
59 | /** |
||
60 | * Load component class from the paths |
||
61 | * |
||
62 | * @param mixed $paths |
||
63 | * @throws \ReflectionException |
||
64 | */ |
||
65 | 48 | protected function loadComponents($paths) |
|
66 | { |
||
67 | 48 | $paths = array_unique(is_array($paths) ? $paths : (array) $paths); |
|
68 | |||
69 | 48 | $paths = array_filter($paths, function ($path) { |
|
70 | 48 | return is_dir($path); |
|
71 | 48 | }); |
|
72 | |||
73 | 48 | if (empty($paths)) { |
|
74 | 48 | return; |
|
75 | } |
||
76 | |||
77 | $namespace = $this->app->getNamespace(); |
||
78 | |||
79 | foreach ((new Finder())->in($paths)->exclude('Observers')->files() as $file) { |
||
80 | $class = trim($namespace, '\\') . '\\' |
||
81 | . str_replace( |
||
82 | ['/', '.php'], |
||
83 | ['\\', ''], |
||
84 | Str::after( |
||
85 | realpath($file->getPathname()), |
||
86 | app_path() . DIRECTORY_SEPARATOR |
||
87 | ) |
||
88 | ); |
||
89 | |||
90 | if (is_subclass_of($class, Component::class) |
||
91 | && ! (new \ReflectionClass($class))->isAbstract() |
||
92 | ) { |
||
93 | $this->registerComponent($class); |
||
94 | } |
||
95 | } |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * register the component class |
||
100 | * |
||
101 | * @param string $class |
||
102 | */ |
||
103 | protected function registerComponent($class) |
||
124 | } |
||
125 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.