Skip to content

Commit 99e812e

Browse files
committed
Register the svg blade directive on CP routes only ...
Prevents conflicts with blade ui kit, or if you were to have a custom svg directive for your own app. Also gives us a place to register CP-only things in the future. Ref #956
1 parent 49e4ce8 commit 99e812e

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Statamic\Http\Middleware\CP;
4+
5+
use Closure;
6+
use Illuminate\Support\Facades\Blade;
7+
8+
class ControlPanel
9+
{
10+
public function handle($request, Closure $next)
11+
{
12+
Blade::directive('svg', function ($expression) {
13+
return "<?php echo Statamic::svg({$expression}) ?>";
14+
});
15+
16+
return $next($request);
17+
}
18+
}

src/Providers/AppServiceProvider.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Routing\Router;
66
use Illuminate\Support\Carbon;
7-
use Illuminate\Support\Facades\Blade;
87
use Illuminate\Support\ServiceProvider;
98
use Statamic\Facades\Preference;
109
use Statamic\Sites\Sites;
@@ -60,10 +59,6 @@ public function boot()
6059
"{$this->root}/resources/views/extend/forms" => resource_path('views/vendor/statamic/forms'),
6160
], 'statamic-forms');
6261

63-
Blade::directive('svg', function ($expression) {
64-
return "<?php echo Statamic::svg({$expression}) ?>";
65-
});
66-
6762
$this->app['redirect']->macro('cpRoute', function ($route, $parameters = []) {
6863
return $this->to(cp_route($route, $parameters));
6964
});

src/Providers/CpServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected function registerMiddlewareGroups()
6868
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
6969
\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class,
7070
\Illuminate\Routing\Middleware\SubstituteBindings::class,
71+
\Statamic\Http\Middleware\CP\ControlPanel::class,
7172
\Statamic\Http\Middleware\CP\ContactOutpost::class,
7273
]);
7374

0 commit comments

Comments
 (0)