|
8 | 8 | use Illuminate\Support\Facades\View;
|
9 | 9 | use Illuminate\Filesystem\Filesystem;
|
10 | 10 | use Illuminate\Contracts\View\Factory;
|
| 11 | +use Illuminate\Support\Facades\Config; |
11 | 12 | use Hexadog\ThemesManager\Traits\ComposerTrait;
|
12 | 13 | use Illuminate\Contracts\Translation\Translator;
|
13 | 14 | use Hexadog\ThemesManager\Exceptions\ThemeNotFoundException;
|
@@ -186,11 +187,27 @@ public function enable(string $name, bool $withEvent = true): ThemesManager
|
186 | 187 | View::addNamespace('theme', "{$path}");
|
187 | 188 | }, $paths);
|
188 | 189 |
|
189 |
| - // TODO: set list of override hints into composer.json |
190 |
| - // Add theme views path to UI-Kit package |
191 |
| - $existingHints = app('view')->getFinder()->getHints(); |
192 |
| - if (!empty($existingHints['package.ui-kit'])) { |
193 |
| - View::replaceNamespace('package.ui-kit', array_merge($paths, $existingHints['package.ui-kit'])); |
| 190 | + // Register all vendor views |
| 191 | + $vendorViews = $theme->getPath('resources/views/vendor'); |
| 192 | + if (File::exists($vendorViews)) { |
| 193 | + $directories = scandir($vendorViews); |
| 194 | + foreach ($directories as $namespace) { |
| 195 | + if ($namespace != '.' && $namespace != '..') { |
| 196 | + $path = "{$vendorViews}{$namespace}"; |
| 197 | + |
| 198 | + if (!empty(Config::get('view.paths')) && |
| 199 | + is_array(Config::get('view.paths')) |
| 200 | + ) { |
| 201 | + foreach (Config::get('view.paths') as $viewPath) { |
| 202 | + if (is_dir($appPath = $viewPath . '/vendor/' . $namespace)) { |
| 203 | + View::prependNamespace($namespace, $appPath); |
| 204 | + } |
| 205 | + } |
| 206 | + } |
| 207 | + |
| 208 | + View::prependNamespace($namespace, $path); |
| 209 | + } |
| 210 | + } |
194 | 211 | }
|
195 | 212 |
|
196 | 213 | // Add Theme language files
|
|
0 commit comments