2016-09-01 16:23:39 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2016-09-02 10:42:05 +01:00
|
|
|
use App\Facade\Theme;
|
|
|
|
use App\Helpers\ThemeHelper;
|
|
|
|
use Illuminate\Support\Facades\View;
|
2016-09-01 16:23:39 +01:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2016-09-02 10:42:05 +01:00
|
|
|
$this->app->singleton('theme', function($app)
|
|
|
|
{
|
|
|
|
return new ThemeHelper();
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->addThemeInfoToView();
|
2016-09-01 16:23:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
2016-09-02 10:42:05 +01:00
|
|
|
|
|
|
|
private function addThemeInfoToView()
|
|
|
|
{
|
|
|
|
$themeInfo = Theme::info();
|
|
|
|
$themeInfoKeys = array('name', 'version');
|
|
|
|
|
|
|
|
// Add each valid theme info element to the view - prefixing with theme_
|
|
|
|
// e.g. $themeInfo['name'] becomes $theme_name in the view
|
|
|
|
foreach ($themeInfoKeys as $key)
|
|
|
|
{
|
|
|
|
if (isset($themeInfo[$key]))
|
|
|
|
{
|
|
|
|
View::share('theme_' . $key, $themeInfo[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Also add a theme_url key
|
|
|
|
View::share('theme_url', sprintf('themes/%s', Theme::current()));
|
|
|
|
}
|
2016-09-01 16:23:39 +01:00
|
|
|
}
|