@@ -30,17 +30,35 @@ public function activate(Composer $composer, IOInterface $io)
30
30
$ this ->io = $ io ;
31
31
}
32
32
33
- public function onPreAutoloadDump ()
33
+ private function getVendorDir ()
34
34
{
35
- $ vendor_dir = str_replace ('\'' , '\\\'' , realpath ($ this ->composer ->getConfig ()->get ('vendor-dir ' )));
36
- $ base_dir = str_replace ('\'' , '\\\'' , getcwd ());
35
+ return str_replace ('\'' , '\\\'' , realpath ($ this ->composer ->getConfig ()->get ('vendor-dir ' )));
36
+ }
37
+
38
+ private function getBaseDir ()
39
+ {
40
+ return str_replace ('\'' , '\\\'' , getcwd ());
41
+ }
42
+
43
+ private function getPath ()
44
+ {
45
+ $ vendor_dir = $ this ->getVendorDir ();
37
46
38
47
if (0 === strpos (__DIR__ , $ vendor_dir ) || strlen (__DIR__ ) - 4 === strpos (__DIR__ , '/src ' )) {
39
48
$ path = __DIR__ . '/ ' ;
40
49
} else {
41
50
$ path = $ vendor_dir . '/hostnet/path-composer-plugin-lib/src/ ' ;
42
51
}
43
52
53
+ return $ path ;
54
+ }
55
+
56
+ public function onPreAutoloadDump ()
57
+ {
58
+ $ path = $ this ->getPath ();
59
+ $ vendor_dir = $ this ->getVendorDir ();
60
+ $ base_dir = $ this ->getBaseDir ();
61
+
44
62
file_put_contents (
45
63
$ path . 'Path.php ' ,
46
64
<<<EOF
@@ -56,4 +74,13 @@ class Path
56
74
EOF
57
75
);
58
76
}
77
+
78
+ public function deactivate (Composer $ composer , IOInterface $ io )
79
+ {
80
+ }
81
+
82
+ public function uninstall (Composer $ composer , IOInterface $ io )
83
+ {
84
+ unlink ($ this ->getPath () . 'Path.php ' );
85
+ }
59
86
}
0 commit comments