]> _ Git - couzy.git/blob
7f7e3ccdd5122812926b37a47b884a0f4d12adb6
[couzy.git] /
1 <?php
2 /*
3  * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
4  *
5  * This file is released under the terms of the MIT license. You can find the
6  * complete text in the attached LICENSE file or online at:
7  *
8  * http://www.opensource.org/licenses/mit-license.php
9  */
10
11 namespace xrstf\Composer52;
12
13 use Composer\Repository\CompositeRepository;
14 use Composer\Script\Event;
15
16 class Generator {
17         public static function onPostInstallCmd(Event $event) {
18                 $composer            = $event->getComposer();
19                 $installationManager = $composer->getInstallationManager();
20                 $repoManager         = $composer->getRepositoryManager();
21                 $localRepo           = $repoManager->getLocalRepository();
22                 $package             = $composer->getPackage();
23                 $config              = $composer->getConfig();
24
25                 // We can't gain access to the Command's input object, so we have to look
26                 // for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works
27                 // (always returns an empty array), nor does Symfony's Console Input, as
28                 // it expects a full definition of the current command line and we can't
29                 // provide that.
30
31 //              $def   = new InputDefinition(array(new InputOption('optimize', 'o', InputOption::VALUE_NONE)));
32 //              $input = new ArgvInput(null, $def);
33 //              var_dump($input->hasOption('o')); // "Too many arguments"
34
35 //              $options  = getopt('o', array('optimize-autoloader')); // always array()
36 //              $optimize = !empty($options);
37
38                 $args     = $_SERVER['argv'];
39                 $optimize = in_array('-o', $args) || in_array('-o', $args);
40
41                 $generator = new AutoloadGenerator();
42                 $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
43         }
44 }