1 | <?php declare(strict_types=1); |
||
18 | final class Scanner |
||
19 | { |
||
20 | /** |
||
21 | * Return all sections (app & plugins) with an Template directory. |
||
22 | * |
||
23 | * @return array |
||
24 | */ |
||
25 | 5 | public static function all(): array |
|
47 | |||
48 | /** |
||
49 | * Return all templates for a given plugin. |
||
50 | * |
||
51 | * @param string $plugin The plugin to find all templates for. |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | 4 | public static function plugin($plugin) |
|
65 | |||
66 | /** |
||
67 | * Check sections a remove the ones without anything in them. |
||
68 | * |
||
69 | * @param array $sections Sections to check. |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | 5 | protected static function clearEmptySections(array $sections): array |
|
83 | |||
84 | /** |
||
85 | * Finds all plugins with a Template directory. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | 5 | protected static function pluginsWithTemplates(): array |
|
90 | { |
||
91 | 5 | $plugins = Plugin::loaded(); |
|
92 | |||
93 | array_walk($plugins, function ($plugin, $index) use (&$plugins) { |
||
|
|||
94 | 5 | $paths = App::path('Template', $plugin); |
|
95 | |||
96 | array_walk($paths, function ($path, $index) use (&$paths) { |
||
97 | 5 | if (!is_dir($path)) { |
|
98 | unset($paths[$index]); |
||
99 | } |
||
100 | 5 | }); |
|
101 | 5 | }); |
|
102 | |||
103 | 5 | return $plugins; |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * Iterage over the given path and return all matching .tpl files in it. |
||
108 | * |
||
109 | * @param string $path Path to iterate over. |
||
110 | * |
||
111 | * @return array |
||
112 | */ |
||
113 | 8 | protected static function iteratePath($path): array |
|
117 | |||
118 | /** |
||
119 | * Setup iterator for given path. |
||
120 | * |
||
121 | * @param string $path Path to setup iterator for. |
||
122 | * |
||
123 | * @return Iterator |
||
124 | */ |
||
125 | 8 | protected static function setupIterator($path): Iterator |
|
138 | |||
139 | /** |
||
140 | * Walk over the iterator and compile all templates. |
||
141 | * |
||
142 | * @param \Iterator $iterator Iterator to walk. |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | 8 | protected static function walkIterator(Iterator $iterator): array |
|
167 | } |
||
168 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.