|
13 | 13 | use Illuminate\View\Compilers\BladeCompiler; |
14 | 14 | use Spatie\Permission\Contracts\Permission as PermissionContract; |
15 | 15 | use Spatie\Permission\Contracts\Role as RoleContract; |
16 | | -use Spatie\Permission\Listeners\OctaneReloadPermissions; |
17 | 16 |
|
18 | 17 | class PermissionServiceProvider extends ServiceProvider |
19 | 18 | { |
@@ -91,17 +90,25 @@ protected function registerCommands(): void |
91 | 90 |
|
92 | 91 | protected function registerOctaneListener(): void |
93 | 92 | { |
94 | | - if ($this->app->runningInConsole() || ! $this->app['config']->get('permission.register_octane_reset_listener')) { |
| 93 | + if ($this->app->runningInConsole() || ! $this->app['config']->get('octane.listeners')) { |
95 | 94 | return; |
96 | 95 | } |
97 | 96 |
|
98 | | - if (! $this->app['config']->get('octane.listeners')) { |
| 97 | + $dispatcher = $this->app[Dispatcher::class]; |
| 98 | + // @phpstan-ignore-next-line |
| 99 | + $dispatcher->listen(function (\Laravel\Octane\Events\OperationTerminated $event) { |
| 100 | + // @phpstan-ignore-next-line |
| 101 | + $event->sandbox->make(PermissionRegistrar::class)->setPermissionsTeamId(null); |
| 102 | + }); |
| 103 | + |
| 104 | + if (! $this->app['config']->get('permission.register_octane_reset_listener')) { |
99 | 105 | return; |
100 | 106 | } |
101 | | - |
102 | | - $dispatcher = $this->app[Dispatcher::class]; |
103 | 107 | // @phpstan-ignore-next-line |
104 | | - $dispatcher->listen(\Laravel\Octane\Events\OperationTerminated::class, OctaneReloadPermissions::class); |
| 108 | + $dispatcher->listen(function (\Laravel\Octane\Events\OperationTerminated $event) { |
| 109 | + // @phpstan-ignore-next-line |
| 110 | + $event->sandbox->make(PermissionRegistrar::class)->clearPermissionsCollection(); |
| 111 | + }); |
105 | 112 | } |
106 | 113 |
|
107 | 114 | protected function registerModelBindings(): void |
|
0 commit comments