From 6cb6925ab4a4fed56ce93eafb8c00770af307c9c Mon Sep 17 00:00:00 2001 From: Giannis Gasteratos Date: Thu, 24 May 2018 07:50:43 +0000 Subject: [PATCH] Fix issue #93: @css('path/to/file.css') no longer working --- src/themeServiceProvider.php | 215 ++++++++++++++++++----------------- 1 file changed, 109 insertions(+), 106 deletions(-) diff --git a/src/themeServiceProvider.php b/src/themeServiceProvider.php index a7e3e6d..9811930 100644 --- a/src/themeServiceProvider.php +++ b/src/themeServiceProvider.php @@ -1,27 +1,28 @@ app->singleton('igaster.themes', function(){ - return new Themes(); - }); + $this->app->singleton('igaster.themes', function () { + return new Themes(); + }); - /*-------------------------------------------------------------------------- - | Replace FileViewFinder - |--------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------- + | Replace FileViewFinder + |--------------------------------------------------------------------------*/ - $this->app->singleton('view.finder', function($app) { + $this->app->singleton('view.finder', function ($app) { return new \Igaster\LaravelTheme\themeViewFinder( $app['files'], $app['config']['view.paths'], @@ -29,39 +30,42 @@ public function register(){ ); }); - /*-------------------------------------------------------------------------- - | Register helpers.php functions - |--------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------- + | Register helpers.php functions + |--------------------------------------------------------------------------*/ require_once 'Helpers/helpers.php'; - /*-------------------------------------------------------------------------- - | Initialize Themes - |--------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------- + | Initialize Themes + |--------------------------------------------------------------------------*/ - $themes = $this->app->make('igaster.themes'); + $themes = $this->app->make('igaster.themes'); $themes->scanThemes(); - /*-------------------------------------------------------------------------- - | Activate default theme - |--------------------------------------------------------------------------*/ - if (!$themes->current() && \Config::get('themes.default')) - $themes->set(\Config::get('themes.default')); + /*-------------------------------------------------------------------------- + | Activate default theme + |--------------------------------------------------------------------------*/ + if (!$themes->current() && \Config::get('themes.default')) { + $themes->set(\Config::get('themes.default')); + } + } - public function boot(){ + public function boot() + { - /*-------------------------------------------------------------------------- - | Pulish configuration file - |--------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------- + | Pulish configuration file + |--------------------------------------------------------------------------*/ - $this->publishes([ - __DIR__.'/Config/themes.php' => config_path('themes.php'), - ], 'laravel-theme'); + $this->publishes([ + __DIR__ . '/Config/themes.php' => config_path('themes.php'), + ], 'laravel-theme'); - /*-------------------------------------------------------------------------- - | Register Console Commands - |--------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------- + | Register Console Commands + |--------------------------------------------------------------------------*/ if ($this->app->runningInConsole()) { $this->commands([ \Igaster\LaravelTheme\Commands\listThemes::class, @@ -73,74 +77,73 @@ public function boot(){ ]); } - /*-------------------------------------------------------------------------- - | Register custom Blade Directives - |--------------------------------------------------------------------------*/ - - $this->registerBladeDirectives(); - } - - protected function registerBladeDirectives(){ - /*-------------------------------------------------------------------------- - | Extend Blade to support Orcherstra\Asset (Asset Managment) - | - | Syntax: - | - | @css (filename, alias, depends-on-alias) - | @js (filename, alias, depends-on-alias) - |--------------------------------------------------------------------------*/ - - Blade::extend(function($value) - { - return preg_replace_callback('/\@js\s*\(\s*([^),]*)(?:,\s*([^),]*))?(?:,\s*([^),]*))?\)/', function($match){ - - $p1 = trim($match[1], " \t\n\r\0\x0B\"'"); - $p2 = trim(empty($match[2]) ? $p1 : $match[2], " \t\n\r\0\x0B\"'"); - $p3 = trim(empty($match[3]) ? '' : $match[3], " \t\n\r\0\x0B\"'"); - - if(empty($p3)) - return ""; - else - return ""; - - },$value); - }); - - \Blade::extend(function ($value) - { - return preg_replace_callback('/\@jsIn\s*\(\s*([^),]*)(?:,\s*([^),]*))?(?:,\s*([^),]*))?(?:,\s*([^),]*))?\)/', - function ($match) { - - $p1 = trim($match[1], " \t\n\r\0\x0B\"'"); - $p2 = trim($match[2], " \t\n\r\0\x0B\"'"); - $p3 = trim(empty($match[3]) ? $p2 : $match[3], " \t\n\r\0\x0B\"'"); - $p4 = trim(empty($match[4]) ? '' : $match[4], " \t\n\r\0\x0B\"'"); - - if (empty($p4)) { - return "script('$p3', theme_url('$p2'));?>"; - } else { - return "script('$p3', theme_url('$p2'), '$p4');?>"; - } - - }, $value); - }); - - - Blade::extend(function($value) - { - return preg_replace_callback('/\@css\s*\(\stheme_url([^),]*)(?:,\s*([^),]*))?(?:,\s*([^),]*))?\)/', function($match){ - - $p1 = trim($match[1], " \t\n\r\0\x0B\"'"); - $p2 = trim(empty($match[2]) ? $p1 : $match[2], " \t\n\r\0\x0B\"'"); - $p3 = trim(empty($match[3]) ? '' : $match[3], " \t\n\r\0\x0B\"'"); - - if(empty($p3)) - return ""; - else - return ""; - - },$value); - }); - } + /*-------------------------------------------------------------------------- + | Register custom Blade Directives + |--------------------------------------------------------------------------*/ + + $this->registerBladeDirectives(); + } + + protected function registerBladeDirectives() + { + /*-------------------------------------------------------------------------- + | Extend Blade to support Orcherstra\Asset (Asset Managment) + | + | Syntax: + | + | @css (filename, alias, depends-on-alias) + | @js (filename, alias, depends-on-alias) + |--------------------------------------------------------------------------*/ + + Blade::extend(function ($value) { + return preg_replace_callback('/\@js\s*\(\s*([^),]*)(?:,\s*([^),]*))?(?:,\s*([^),]*))?\)/', function ($match) { + + $p1 = trim($match[1], " \t\n\r\0\x0B\"'"); + $p2 = trim(empty($match[2]) ? $p1 : $match[2], " \t\n\r\0\x0B\"'"); + $p3 = trim(empty($match[3]) ? '' : $match[3], " \t\n\r\0\x0B\"'"); + + if (empty($p3)) { + return ""; + } else { + return ""; + } + + }, $value); + }); + + Blade::extend(function ($value) { + return preg_replace_callback('/\@jsIn\s*\(\s*([^),]*)(?:,\s*([^),]*))?(?:,\s*([^),]*))?(?:,\s*([^),]*))?\)/', + function ($match) { + + $p1 = trim($match[1], " \t\n\r\0\x0B\"'"); + $p2 = trim($match[2], " \t\n\r\0\x0B\"'"); + $p3 = trim(empty($match[3]) ? $p2 : $match[3], " \t\n\r\0\x0B\"'"); + $p4 = trim(empty($match[4]) ? '' : $match[4], " \t\n\r\0\x0B\"'"); + + if (empty($p4)) { + return "script('$p3', theme_url('$p2'));?>"; + } else { + return "script('$p3', theme_url('$p2'), '$p4');?>"; + } + + }, $value); + }); + + Blade::extend(function ($value) { + return preg_replace_callback('/\@css\s*\(\s*([^),]*)(?:,\s*([^),]*))?(?:,\s*([^),]*))?\)/', function ($match) { + + $p1 = trim($match[1], " \t\n\r\0\x0B\"'"); + $p2 = trim(empty($match[2]) ? $p1 : $match[2], " \t\n\r\0\x0B\"'"); + $p3 = trim(empty($match[3]) ? '' : $match[3], " \t\n\r\0\x0B\"'"); + + if (empty($p3)) { + return ""; + } else { + return ""; + } + + }, $value); + }); + } }