Application.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Console;
  12. use Symfony\Component\Console\Application as BaseApplication;
  13. use Symfony\Component\Console\Input\InputInterface;
  14. use Symfony\Component\Console\Output\OutputInterface;
  15. use Symfony\Component\Finder\Finder;
  16. use Composer\Command;
  17. use Composer\Composer;
  18. /**
  19. * The console application that handles the commands
  20. *
  21. * @author Ryan Weaver <ryan@knplabs.com>
  22. */
  23. class Application extends BaseApplication
  24. {
  25. private $composer;
  26. public function __construct(Composer $composer)
  27. {
  28. parent::__construct('Composer', Composer::VERSION);
  29. $this->composer = $composer;
  30. }
  31. /**
  32. * Runs the current application.
  33. *
  34. * @param InputInterface $input An Input instance
  35. * @param OutputInterface $output An Output instance
  36. *
  37. * @return integer 0 if everything went fine, or an error code
  38. */
  39. public function doRun(InputInterface $input, OutputInterface $output)
  40. {
  41. $this->registerCommands();
  42. return parent::doRun($input, $output);
  43. }
  44. /**
  45. * @return Composer
  46. */
  47. public function getComposer()
  48. {
  49. return $this->composer;
  50. }
  51. /**
  52. * Initializes all the composer commands
  53. */
  54. protected function registerCommands()
  55. {
  56. $this->add(new Command\HelpCommand());
  57. $this->add(new Command\InstallCommand());
  58. $this->add(new Command\UpdateCommand());
  59. $this->add(new Command\DebugPackagesCommand());
  60. }
  61. }