1212use Composer \IO \IOInterface ;
1313use Composer \Package \PackageInterface ;
1414use Composer \Plugin \PluginInterface ;
15+ use Composer \Script \Event ;
16+ use Composer \Script \ScriptEvents ;
1517
1618final class NoFinalClassPlugin implements PluginInterface, EventSubscriberInterface
1719{
@@ -27,6 +29,8 @@ public static function getSubscribedEvents()
2729 return [
2830 PackageEvents::POST_PACKAGE_INSTALL => 'onPackageInstall ' ,
2931 PackageEvents::POST_PACKAGE_UPDATE => 'onPackageUpdate ' ,
32+ ScriptEvents::POST_INSTALL_CMD => 'onInstallCmd ' ,
33+ ScriptEvents::POST_UPDATE_CMD => 'onUpdateCmd ' ,
3034 ];
3135 }
3236
@@ -56,10 +60,20 @@ public function onPackageUpdate(PackageEvent $event)
5660 $ this ->removeFinalFromAllEasyAdminClasses ();
5761 }
5862
63+ public function onInstallCmd (Event $ event )
64+ {
65+ $ this ->removeFinalFromAllEasyAdminClasses ();
66+ }
67+
68+ public function onUpdateCmd (Event $ event )
69+ {
70+ $ this ->removeFinalFromAllEasyAdminClasses ();
71+ }
72+
5973 public function removeFinalFromAllEasyAdminClasses ()
6074 {
6175 $ vendorDirPath = $ this ->getVendorDirPath ();
62- $ easyAdminDirPath = $ vendorDirPath. '/easycorp/easyadmin-bundle ' ;
76+ $ easyAdminDirPath = $ vendorDirPath . '/easycorp/easyadmin-bundle ' ;
6377 foreach ($ this ->getFilePathsOfAllEasyAdminClasses ($ easyAdminDirPath ) as $ filePath ) {
6478 file_put_contents (
6579 $ filePath ,
@@ -95,7 +109,7 @@ private function getVendorDirPath(): string
95109 $ composerJsonContents = json_decode (file_get_contents ($ composerJsonFilePath ), associative: true , flags: JSON_THROW_ON_ERROR );
96110 $ projectDir = dirname (realpath ($ composerJsonFilePath ));
97111
98- return $ composerJsonContents ['config ' ]['vendor-dir ' ] ?? $ projectDir. '/vendor ' ;
112+ return $ composerJsonContents ['config ' ]['vendor-dir ' ] ?? $ projectDir . '/vendor ' ;
99113 }
100114
101115 /**
0 commit comments