12
12
use Composer \IO \IOInterface ;
13
13
use Composer \Package \PackageInterface ;
14
14
use Composer \Plugin \PluginInterface ;
15
+ use Composer \Script \Event ;
16
+ use Composer \Script \ScriptEvents ;
15
17
16
18
final class NoFinalClassPlugin implements PluginInterface, EventSubscriberInterface
17
19
{
@@ -27,6 +29,8 @@ public static function getSubscribedEvents()
27
29
return [
28
30
PackageEvents::POST_PACKAGE_INSTALL => 'onPackageInstall ' ,
29
31
PackageEvents::POST_PACKAGE_UPDATE => 'onPackageUpdate ' ,
32
+ ScriptEvents::POST_INSTALL_CMD => 'onInstallCmd ' ,
33
+ ScriptEvents::POST_UPDATE_CMD => 'onUpdateCmd ' ,
30
34
];
31
35
}
32
36
@@ -56,10 +60,20 @@ public function onPackageUpdate(PackageEvent $event)
56
60
$ this ->removeFinalFromAllEasyAdminClasses ();
57
61
}
58
62
63
+ public function onInstallCmd (Event $ event )
64
+ {
65
+ $ this ->removeFinalFromAllEasyAdminClasses ();
66
+ }
67
+
68
+ public function onUpdateCmd (Event $ event )
69
+ {
70
+ $ this ->removeFinalFromAllEasyAdminClasses ();
71
+ }
72
+
59
73
public function removeFinalFromAllEasyAdminClasses ()
60
74
{
61
75
$ vendorDirPath = $ this ->getVendorDirPath ();
62
- $ easyAdminDirPath = $ vendorDirPath. '/easycorp/easyadmin-bundle ' ;
76
+ $ easyAdminDirPath = $ vendorDirPath . '/easycorp/easyadmin-bundle ' ;
63
77
foreach ($ this ->getFilePathsOfAllEasyAdminClasses ($ easyAdminDirPath ) as $ filePath ) {
64
78
file_put_contents (
65
79
$ filePath ,
@@ -95,7 +109,7 @@ private function getVendorDirPath(): string
95
109
$ composerJsonContents = json_decode (file_get_contents ($ composerJsonFilePath ), associative: true , flags: JSON_THROW_ON_ERROR );
96
110
$ projectDir = dirname (realpath ($ composerJsonFilePath ));
97
111
98
- return $ composerJsonContents ['config ' ]['vendor-dir ' ] ?? $ projectDir. '/vendor ' ;
112
+ return $ composerJsonContents ['config ' ]['vendor-dir ' ] ?? $ projectDir . '/vendor ' ;
99
113
}
100
114
101
115
/**
0 commit comments