Better handling of the custom theme settings.

This commit is contained in:
James Brooks
2015-05-19 15:41:29 +01:00
parent 0b58160f6d
commit 4d28b28bdf
3 changed files with 46 additions and 4 deletions

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Cachet.
*
* (c) James Brooks <james@cachethq.io>
* (c) Joseph Cohen <joseph.cohen@dinkbit.com>
* (c) Graham Campbell <graham@mineuk.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Composers;
use CachetHQ\Cachet\Facades\Setting;
use Illuminate\View\View;
class ThemeComposer
{
/**
* Bind data to the view.
*
* @param \Illuminate\View\View $view
*/
public function compose(View $view)
{
$view->with('themeBackgroundColor', Setting::get('style_background_color') ?: null);
$view->with('themeTextColor', Setting::get('style_text_color') ?: null);
$viewData = $view->getData();
$themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
$hasThemeSettings = array_filter($themeView, function ($data) {
return $data != null;
});
$view->with('themeSetup', !empty($hasThemeSettings));
}
}

View File

@@ -32,6 +32,7 @@ class ViewComposerServiceProvider extends ServiceProvider
{
$this->app->view->composer('*', 'CachetHQ\Cachet\Composers\LoggedUserComposer');
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\IndexComposer');
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\ThemeComposer');
$this->app->view->composer('dashboard.*', 'CachetHQ\Cachet\Composers\DashboardComposer');
$this->app->view->composer([
'setup',