GenerateProxyClassApplication.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Drupal\Core\Command;
  3. use Drupal\Component\ProxyBuilder\ProxyBuilder;
  4. use Symfony\Component\Console\Application;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. /**
  7. * Provides a console command to generate proxy classes.
  8. */
  9. class GenerateProxyClassApplication extends Application {
  10. /**
  11. * The proxy builder.
  12. *
  13. * @var \Drupal\Component\ProxyBuilder\ProxyBuilder
  14. */
  15. protected $proxyBuilder;
  16. /**
  17. * Constructs a new GenerateProxyClassApplication instance.
  18. *
  19. * @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder
  20. * The proxy builder.
  21. */
  22. public function __construct(ProxyBuilder $proxy_builder) {
  23. $this->proxyBuilder = $proxy_builder;
  24. parent::__construct();
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected function getCommandName(InputInterface $input) {
  30. return 'generate-proxy-class';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. protected function getDefaultCommands() {
  36. // Even though this is a single command, keep the HelpCommand (--help).
  37. $default_commands = parent::getDefaultCommands();
  38. $default_commands[] = new GenerateProxyClassCommand($this->proxyBuilder);
  39. return $default_commands;
  40. }
  41. /**
  42. * {@inheritdoc}
  43. *
  44. * Overridden so the application doesn't expect the command name as the first
  45. * argument.
  46. */
  47. public function getDefinition() {
  48. $definition = parent::getDefinition();
  49. // Clears the normal first argument (the command name).
  50. $definition->setArguments();
  51. return $definition;
  52. }
  53. }