Exemplo n.º 1
0
 public static function onPostInstallCmd(Event $event)
 {
     $composer = $event->getComposer();
     $installationManager = $composer->getInstallationManager();
     $repoManager = $composer->getRepositoryManager();
     $localRepo = $repoManager->getLocalRepository();
     $package = $composer->getPackage();
     $config = $composer->getConfig();
     // We can't gain access to the Command's input object, so we have to look
     // for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works
     // (always returns an empty array), nor does Symfony's Console Input, as
     // it expects a full definition of the current command line and we can't
     // provide that.
     $args = $_SERVER['argv'];
     $optimize = in_array('-o', $args) || in_array('--optimize-autoloader', $args) || in_array('--optimize', $args);
     $suffix = $config->get('autoloader-suffix');
     $generator = new AutoloadGenerator();
     $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize, $suffix);
 }
Exemplo n.º 2
0
 public static function onPostInstallCmd(Event $event)
 {
     $composer = $event->getComposer();
     $installationManager = $composer->getInstallationManager();
     $repoManager = $composer->getRepositoryManager();
     $localRepo = $repoManager->getLocalRepository();
     $package = $composer->getPackage();
     $config = $composer->getConfig();
     // We can't gain access to the Command's input object, so we have to look
     // for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works
     // (always returns an empty array), nor does Symfony's Console Input, as
     // it expects a full definition of the current command line and we can't
     // provide that.
     //		$def   = new InputDefinition(array(new InputOption('optimize', 'o', InputOption::VALUE_NONE)));
     //		$input = new ArgvInput(null, $def);
     //		var_dump($input->hasOption('o')); // "Too many arguments"
     //		$options  = getopt('o', array('optimize-autoloader')); // always array()
     //		$optimize = !empty($options);
     $args = $_SERVER['argv'];
     $optimize = in_array('-o', $args) || in_array('-o', $args);
     $generator = new AutoloadGenerator();
     $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
 }