1 | <?php |
||
29 | class Plugin implements PluginInterface, EventSubscriberInterface |
||
30 | { |
||
31 | const PACKAGE_TYPE = 'yii2-extension'; |
||
32 | const EXTRA_CONFIG = 'yii2-extraconfig'; |
||
33 | const EXTENSIONS_FILE = 'yiisoft/extensions.php'; |
||
34 | const EXTRACONFIG_FILE = 'yiisoft/yii2-extraconfig.php'; |
||
35 | const BASE_DIR_ALIAS = '<base-dir>'; |
||
36 | const VENDOR_DIR_ALIAS = '<base-dir>/vendor'; |
||
37 | |||
38 | /** |
||
39 | * @var PackageInterface[] the array of active composer packages |
||
40 | */ |
||
41 | protected $packages; |
||
42 | |||
43 | /** |
||
44 | * @var string absolute path to the package base directory. |
||
45 | */ |
||
46 | protected $baseDir; |
||
47 | |||
48 | /** |
||
49 | * @var string absolute path to vendor directory. |
||
50 | */ |
||
51 | protected $vendorDir; |
||
52 | |||
53 | /** |
||
54 | * @var Filesystem utility |
||
55 | */ |
||
56 | protected $filesystem; |
||
57 | |||
58 | /** |
||
59 | * @var array extra configuration |
||
60 | */ |
||
61 | protected $extraconfig = [ |
||
62 | 'aliases' => [ |
||
63 | '@vendor' => self::VENDOR_DIR_ALIAS, |
||
64 | ], |
||
65 | ]; |
||
66 | |||
67 | /** |
||
68 | * @var array extensions |
||
69 | */ |
||
70 | protected $extensions = []; |
||
71 | |||
72 | /** |
||
73 | * @var Composer instance |
||
74 | */ |
||
75 | protected $composer; |
||
76 | |||
77 | /** |
||
78 | * @var IOInterface |
||
79 | */ |
||
80 | public $io; |
||
81 | |||
82 | /** |
||
83 | * Initializes the plugin object with the passed $composer and $io. |
||
84 | * @param Composer $composer |
||
85 | * @param IOInterface $io |
||
86 | * @void |
||
87 | */ |
||
88 | 2 | public function activate(Composer $composer, IOInterface $io) |
|
93 | |||
94 | /** |
||
95 | * Returns list of events the plugin is subscribed to. |
||
96 | * @return array list of events |
||
97 | */ |
||
98 | 1 | public static function getSubscribedEvents() |
|
106 | |||
107 | /** |
||
108 | * Simply rewrites extensions file from scratch. |
||
109 | * @param Event $event |
||
110 | * @void |
||
111 | */ |
||
112 | public function onPostAnything(Event $event) |
||
126 | |||
127 | /** |
||
128 | * Writes file. |
||
129 | * @param string $file |
||
130 | * @param array $data |
||
131 | * @void |
||
132 | */ |
||
133 | protected function saveFile($file, array $data) |
||
142 | |||
143 | /** |
||
144 | * Scans the given package and collects extensions data. |
||
145 | * @param PackageInterface $package |
||
146 | * @void |
||
147 | */ |
||
148 | public function processPackage(PackageInterface $package) |
||
173 | |||
174 | public function extractConfigPath(PackageInterface $package) |
||
179 | |||
180 | /** |
||
181 | * Read extra config. |
||
182 | * @param string $file |
||
183 | * @return array |
||
184 | */ |
||
185 | protected function readExtraConfig(PackageInterface $package, $file) |
||
194 | |||
195 | /** |
||
196 | * Prepare aliases. |
||
197 | * |
||
198 | * @param PackageInterface $package |
||
199 | * @param string 'psr-0' or 'psr-4' |
||
200 | * @return array |
||
201 | */ |
||
202 | protected function prepareAliases(PackageInterface $package, $psr) |
||
227 | |||
228 | /** |
||
229 | * Substitute path with alias if applicable. |
||
230 | * @param string $path |
||
231 | * @param string $dir |
||
232 | * @param string $alias |
||
233 | * @return string |
||
234 | */ |
||
235 | public function substitutePath($path, $dir, $alias) |
||
239 | |||
240 | public function preparePath(PackageInterface $package, $path) |
||
249 | |||
250 | /** |
||
251 | * Sets [[packages]]. |
||
252 | * @param PackageInterface[] $packages |
||
253 | * @void |
||
254 | */ |
||
255 | 2 | public function setPackages(array $packages) |
|
259 | |||
260 | /** |
||
261 | * Gets [[packages]]. |
||
262 | * @return \Composer\Package\PackageInterface[] |
||
263 | */ |
||
264 | 1 | public function getPackages() |
|
272 | |||
273 | /** |
||
274 | * Get absolute path to package base dir. |
||
275 | * @return string |
||
276 | */ |
||
277 | public function getBaseDir() |
||
285 | |||
286 | /** |
||
287 | * Get absolute path to composer vendor dir. |
||
288 | * @return string |
||
289 | */ |
||
290 | public function getVendorDir() |
||
299 | |||
300 | /** |
||
301 | * Getter for filesystem utility. |
||
302 | * @return Filesystem |
||
303 | */ |
||
304 | public function getFilesystem() |
||
312 | } |
||
313 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.