/wp-content/plugins/wordpress-seo/vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php
PHP | 44 lines | 18 code | 8 blank | 18 comment | 1 complexity | 417df818c0f1b500c094ef76f3703caa MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, GPL-3.0, BSD-3-Clause, Apache-2.0, MIT, AGPL-1.0, LGPL-2.1
- <?php
- /*
- * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
- *
- * This file is released under the terms of the MIT license. You can find the
- * complete text in the attached LICENSE file or online at:
- *
- * http://www.opensource.org/licenses/mit-license.php
- */
- namespace xrstf\Composer52;
- use Composer\Repository\CompositeRepository;
- use Composer\Script\Event;
- class Generator {
- 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);
- }
- }