Symfony\Component\Console\Command\Command::mergeApplicationDefinition PHP Method

mergeApplicationDefinition() public method

This method is not part of public API and should not be used directly.
public mergeApplicationDefinition ( boolean $mergeArgs = true )
$mergeArgs boolean Whether to merge or not the Application definition arguments to Command definition arguments
    public function mergeApplicationDefinition($mergeArgs = true)
    {
        if (null === $this->application || true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs)) {
            return;
        }
        $this->definition->addOptions($this->application->getDefinition()->getOptions());
        if ($mergeArgs) {
            $currentArguments = $this->definition->getArguments();
            $this->definition->setArguments($this->application->getDefinition()->getArguments());
            $this->definition->addArguments($currentArguments);
        }
        $this->applicationDefinitionMerged = true;
        if ($mergeArgs) {
            $this->applicationDefinitionMergedWithArgs = true;
        }
    }

Usage Example

 /**
  * @param Command $command
  * @param InputInterface $input
  */
 protected function addOptionsToCommand(Command $command, InputInterface $input)
 {
     $inputDefinition = $command->getApplication()->getDefinition();
     $inputDefinition->addOption(new InputOption(self::DISABLE_OPTIONAL_LISTENERS, null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, sprintf('Disable optional listeners, "%s" to disable all listeners, ' . 'command "%s" shows all listeners', self::ALL_OPTIONAL_LISTENERS_VALUE, OptionalListenersCommand::NAME)));
     $command->mergeApplicationDefinition();
     $input->bind($command->getDefinition());
 }
All Usage Examples Of Symfony\Component\Console\Command\Command::mergeApplicationDefinition