hasArgument() public method

Checks if an argument of the given name exists (is set)
public hasArgument ( string $argumentName ) : boolean
$argumentName string Name of the argument to check
return boolean TRUE if the argument is set, otherwise FALSE
コード例 #1
0
 /**
  * Maps arguments delivered by the request object to the local controller arguments.
  *
  * @return void
  */
 protected function mapRequestArgumentsToControllerArguments()
 {
     /** @var Argument $argument */
     foreach ($this->arguments as $argument) {
         $argumentName = $argument->getName();
         if ($this->request->hasArgument($argumentName)) {
             $argument->setValue($this->request->getArgument($argumentName));
             continue;
         }
         if (!$argument->isRequired()) {
             continue;
         }
         $argumentValue = null;
         while ($argumentValue === null) {
             $argumentValue = $this->output->ask(sprintf('<comment>Please specify the required argument "%s":</comment> ', $argumentName));
         }
         if ($argumentValue === null) {
             $exception = new CommandException(sprintf('Required argument "%s" is not set.', $argumentName), 1306755520);
             $this->forward('error', HelpCommandController::class, ['exception' => $exception]);
         }
         $argument->setValue($argumentValue);
     }
 }