Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed service registration so it won't break when no 'themes' folder yet exists. #65

Merged
merged 1 commit into from
Nov 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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