Neos\Flow\Mvc\Controller\Arguments::addNewArgument PHP Метод

addNewArgument() публичный Метод

If an argument with the same name exists already, it will be replaced by the new argument object.
public addNewArgument ( string $name, string $dataType = 'string', boolean $isRequired = true, mixed $defaultValue = null ) : Argument
$name string Name of the argument
$dataType string Name of one of the built-in data types
$isRequired boolean TRUE if this argument should be marked as required
$defaultValue mixed Default value of the argument. Only makes sense if $isRequired==FALSE
Результат Argument The new argument
    public function addNewArgument($name, $dataType = 'string', $isRequired = true, $defaultValue = null)
    {
        $argument = new Argument($name, $dataType);
        $argument->setRequired($isRequired);
        $argument->setDefaultValue($defaultValue);
        $this->addArgument($argument);
        return $argument;
    }

Usage Example

 /**
  * @test
  */
 public function processRequestResetsCommandMethodArguments()
 {
     $mockRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $mockResponse = $this->getMockBuilder(Mvc\ResponseInterface::class)->getMock();
     $mockArguments = new Arguments();
     $mockArguments->addNewArgument('foo');
     $this->inject($this->commandController, 'arguments', $mockArguments);
     $this->assertCount(1, $this->commandController->_get('arguments'));
     $this->commandController->processRequest($mockRequest, $mockResponse);
     $this->assertCount(0, $this->commandController->_get('arguments'));
 }
All Usage Examples Of Neos\Flow\Mvc\Controller\Arguments::addNewArgument