File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Laravel \Telescope \Actions ;
4+
5+ use Illuminate \Support \ServiceProvider ;
6+
7+ class UninstallAction
8+ {
9+ public function handle (): void
10+ {
11+ if (method_exists (ServiceProvider::class, 'removeProviderFromBootstrapFile ' ) &&
12+ ServiceProvider::removeProviderFromBootstrapFile ('TelescopeServiceProvider ' )) {
13+ return ;
14+ }
15+ }
16+ }
Original file line number Diff line number Diff line change 44
55use Illuminate \Support \Facades \Route ;
66use Illuminate \Support \ServiceProvider ;
7+ use Laravel \Telescope \Actions \UninstallAction ;
78use Laravel \Telescope \Contracts \ClearableRepository ;
89use Laravel \Telescope \Contracts \EntriesRepository ;
910use Laravel \Telescope \Contracts \PrunableRepository ;
@@ -20,6 +21,7 @@ public function boot()
2021 {
2122 $ this ->registerCommands ();
2223 $ this ->registerPublishing ();
24+ $ this ->registerPrePackageUninstallListener ();
2325
2426 if (! config ('telescope.enabled ' )) {
2527 return ;
@@ -161,4 +163,14 @@ protected function registerDatabaseDriver()
161163 ->needs ('$chunkSize ' )
162164 ->give (config ('telescope.storage.database.chunk ' ));
163165 }
166+
167+ /**
168+ * Register a pre-package uninstallation listener.
169+ */
170+ protected function registerPrePackageUninstallListener (): void
171+ {
172+ $ this ->app ['events ' ]->listen ('composer_package.laravel/telescope:pre_uninstall ' , function () {
173+ $ this ->app ->make (UninstallAction::class)->handle ();
174+ });
175+ }
164176}
You can’t perform that action at this time.
0 commit comments