Skip to content

Commit

Permalink
[Fixes BIG bug] register blade directives after resolving blade compi…
Browse files Browse the repository at this point in the history
…ler (#2048)

* register blade directives after resolving blade compiler

Fixes #2038, #2044, #2045

* use callAfterResolving instead of afterResolving
  • Loading branch information
tabacitu committed Mar 9, 2022
1 parent 677903c commit eb838cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/PermissionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;
use Spatie\Permission\Contracts\Permission as PermissionContract;
use Spatie\Permission\Contracts\Role as RoleContract;

Expand Down Expand Up @@ -39,7 +40,9 @@ public function register()
'permission'
);

$this->registerBladeExtensions();
$this->callAfterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
$this->registerBladeExtensions($bladeCompiler);
});
}

protected function offerPublishing()
Expand Down Expand Up @@ -81,10 +84,8 @@ protected function registerModelBindings()
$this->app->bind(RoleContract::class, $config['role']);
}

protected function registerBladeExtensions()
protected function registerBladeExtensions($bladeCompiler)
{
$bladeCompiler = $this->app['blade.compiler'];

$bladeCompiler->directive('role', function ($arguments) {
list($role, $guard) = explode(',', $arguments.',');

Expand Down

0 comments on commit eb838cd

Please sign in to comment.