File tree Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Expand file tree Collapse file tree 3 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "name" : " friendsofsymfony1/symfony1-installer-plugin" ,
3+ "type" : " composer-plugin" ,
4+ "license" : " MIT" ,
5+ "autoload" : {
6+ "psr-4" : {"Symfony1\\ Composer\\ " : " src/" }
7+ },
8+ "extra" : {
9+ "class" : " Symfony1\\ Composer\\ InstallerPlugin"
10+ },
11+ "require" : {
12+ "php" : " ^7.4 || ^8.0" ,
13+ "composer-plugin-api" : " ^2.8"
14+ },
15+ "require-dev" : {
16+ "composer/composer" : " ^2.8"
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Symfony1 \Composer ;
4+
5+ use Composer \Installer \LibraryInstaller ;
6+ use Composer \Package \PackageInterface ;
7+
8+ class Installer extends LibraryInstaller
9+ {
10+ public function getInstallPath (PackageInterface $ package ): string
11+ {
12+ $ prettyName = $ package ->getPrettyName ();
13+ if (str_contains ($ prettyName , '/ ' )) {
14+ $ name = explode ('/ ' , $ prettyName )[1 ];
15+ } else {
16+ $ name = $ prettyName ;
17+ }
18+
19+ $ camelCaseName = preg_replace_callback ('/-([a-z])/ ' , static fn ($ m ) => strtoupper ($ m [1 ]), $ name );
20+
21+ return 'plugins/ ' .$ camelCaseName ;
22+ }
23+
24+ public function supports ($ packageType ): bool
25+ {
26+ return 'symfony1-plugin ' === $ packageType ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Symfony1 \Composer ;
4+
5+ use Composer \Composer ;
6+ use Composer \IO \IOInterface ;
7+ use Composer \Plugin \PluginInterface ;
8+
9+ class InstallerPlugin implements PluginInterface
10+ {
11+ public function activate (Composer $ composer , IOInterface $ io ): void
12+ {
13+ $ installer = new Installer ($ io , $ composer );
14+ $ composer ->getInstallationManager ()->addInstaller ($ installer );
15+ }
16+
17+ public function deactivate (Composer $ composer , IOInterface $ io ): void
18+ {
19+ $ installer = new Installer ($ io , $ composer );
20+ $ composer ->getInstallationManager ()->removeInstaller ($ installer );
21+ }
22+
23+ public function uninstall (Composer $ composer , IOInterface $ io ): void
24+ {
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments