Neos\Flow\Mvc\Controller\Arguments::addArgument PHP Méthode

addArgument() public méthode

If an argument with the same name exists already, it will be replaced by the new argument object. Note that the argument will be cloned, not referenced.
public addArgument ( Argument $argument ) : void
$argument Argument The argument to add
Résultat void
    public function addArgument(Argument $argument)
    {
        $this->offsetSet(null, $argument);
    }

Usage Example

 /**
  * @test
  */
 public function getValidationResultsShouldFetchAllValidationResltsFromArguments()
 {
     $error1 = new FlowError\Error('Validation error', 1234);
     $error2 = new FlowError\Error('Validation error 2', 1235);
     $results1 = new FlowError\Result();
     $results1->addError($error1);
     $results2 = new FlowError\Result();
     $results2->addError($error2);
     $argument1 = $this->getMockBuilder(Argument::class)->setMethods(['getValidationResults'])->setConstructorArgs(['name1', 'string'])->getMock();
     $argument1->expects($this->once())->method('getValidationResults')->will($this->returnValue($results1));
     $argument2 = $this->getMockBuilder(Argument::class)->setMethods(['getValidationResults'])->setConstructorArgs(['name2', 'string'])->getMock();
     $argument2->expects($this->once())->method('getValidationResults')->will($this->returnValue($results2));
     $arguments = new Arguments();
     $arguments->addArgument($argument1);
     $arguments->addArgument($argument2);
     $this->assertSame(['name1' => [$error1], 'name2' => [$error2]], $arguments->getValidationResults()->getFlattenedErrors());
 }