File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use Symfony\Component\Filesystem\Filesystem;
99
1010@set_time_limit (0 );
1111
12- $ _SERVER ['DOCUMENT_ROOT ' ] = __DIR__ . DIRECTORY_SEPARATOR . '../../../.. ' ;
12+ $ _SERVER ['DOCUMENT_ROOT ' ] = __DIR__ . DIRECTORY_SEPARATOR . '../../../.. ' ;
1313$ GLOBALS ['DOCUMENT_ROOT ' ] = $ _SERVER ['DOCUMENT_ROOT ' ];
1414
1515$ autoloadPath = $ _SERVER ['DOCUMENT_ROOT ' ] . '/vendor/autoload.php ' ;
Original file line number Diff line number Diff line change 2121 },
2222 "autoload" : {
2323 "psr-4" : {"ProklUng\\ ModuleGenerator\\ " : " src" }
24+ },
25+ "scripts" : {
26+ "post-update-cmd" : [
27+ " ProklUng\\ ComposerScript\\ InstallUpdateHandler::doInstall"
28+ ],
29+ "post-install-cmd" : [
30+ " ProklUng\\ ComposerScript\\ InstallUpdateHandler::doInstall"
31+ ]
2432 }
2533}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace ProklUng \ModuleGenerator \ComposerScript ;
4+
5+ use Composer \Script \Event ;
6+ use InvalidArgumentException ;
7+ use Symfony \Component \Filesystem \Exception \IOException ;
8+ use Symfony \Component \Filesystem \Filesystem ;
9+
10+ /**
11+ * Class InstallUpdateHandler
12+ * @package Local\ComposerScript
13+ */
14+ class InstallUpdateHandler
15+ {
16+ /**
17+ * @param Event $event
18+ *
19+ * @throws InvalidArgumentException
20+ */
21+ public static function doInstall (Event $ event ): void
22+ {
23+ $ io = $ event ->getIO ();
24+
25+ $ vendorDir = $ event ->getComposer ()->getConfig ()->get ('vendor-dir ' );
26+
27+ $ projectRoot = realpath ($ vendorDir . '/../ ' );
28+
29+ if (!is_dir ($ projectRoot ) || !is_readable ($ projectRoot ) || !is_writable ($ projectRoot )) {
30+ $ io ->write (
31+ \sprintf (
32+ '<error>Directory "%s" is not writable. Aborting</error> ' ,
33+ $ projectRoot
34+ )
35+ );
36+
37+ return ;
38+ }
39+
40+ $ filesystem = new Filesystem ();
41+ try {
42+ $ filesystem ->mirror (
43+ __DIR__ .'/bin/ ' ,
44+ $ projectRoot . '/bin/ '
45+ );
46+ } catch (IOException $ e ) {
47+ $ io ->write ('<error>Error copy command for generate modules : ' . $ e ->getMessage () . '</error> ' );
48+ }
49+
50+ $ io ->write ('Console command for generate modules successfully installed. ' );
51+ }
52+ }
You can’t perform that action at this time.
0 commit comments