PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/wordpress-seo/vendor/xrstf/composer-php52/lib/xrstf/Composer52/Generator.php

https://github.com/CaffeinatedJim/catsinmyyard
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
  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. namespace xrstf\Composer52;
  11. use Composer\Repository\CompositeRepository;
  12. use Composer\Script\Event;
  13. class Generator {
  14. public static function onPostInstallCmd(Event $event) {
  15. $composer = $event->getComposer();
  16. $installationManager = $composer->getInstallationManager();
  17. $repoManager = $composer->getRepositoryManager();
  18. $localRepo = $repoManager->getLocalRepository();
  19. $package = $composer->getPackage();
  20. $config = $composer->getConfig();
  21. // We can't gain access to the Command's input object, so we have to look
  22. // for -o / --optimize-autoloader ourselves. Sadly, neither getopt() works
  23. // (always returns an empty array), nor does Symfony's Console Input, as
  24. // it expects a full definition of the current command line and we can't
  25. // provide that.
  26. // $def = new InputDefinition(array(new InputOption('optimize', 'o', InputOption::VALUE_NONE)));
  27. // $input = new ArgvInput(null, $def);
  28. // var_dump($input->hasOption('o')); // "Too many arguments"
  29. // $options = getopt('o', array('optimize-autoloader')); // always array()
  30. // $optimize = !empty($options);
  31. $args = $_SERVER['argv'];
  32. $optimize = in_array('-o', $args) || in_array('-o', $args);
  33. $generator = new AutoloadGenerator();
  34. $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  35. }
  36. }