Skip to content

Commit

Permalink
Fixed service registration so it won't break when no 'themes' folder …
Browse files Browse the repository at this point in the history
…yet exists. (#65)
  • Loading branch information
mpenna authored and kaidesu committed Nov 22, 2017
1 parent eb26b28 commit 5dea58e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/ThemesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,35 @@ public function provides()
protected function registerServices()
{
$this->app->singleton('caffeinated.themes', function($app) {
$themes = $this->app['files']->directories(config('themes.paths.absolute'));

$themes = [];
$items = [];

if ($path = config('themes.paths.absolute')) {
if (file_exists($path) && is_dir($path)) {
$themes = $this->app['files']->directories($path);
}
}

foreach ($themes as $theme) {
$manifest = new Manifest($theme.'/theme.json');

$items[] = $manifest;
}
return new Theme($items);

return new Theme($items);
});

$this->app->singleton('view.finder', function($app) {
return new ThemeViewFinder($app['files'], $app['config']['view.paths'], null);
});
}

/**
* Register the theme namespaces.
*/
protected function registerNamespaces()
{
$themes = app('caffeinated.themes')->all();

foreach ($themes as $theme) {
app('view')->addNamespace($theme->get('slug'), app('caffeinated.themes')->getAbsolutePath($theme->get('slug')).'/views');
}
Expand Down

0 comments on commit 5dea58e

Please sign in to comment.