Neos\Flow\ObjectManagement\Configuration\Configuration::setArguments PHP Метод

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

Setter function for injection constructor arguments. If an empty array is passed to this method, all (possibly) defined constructor arguments are removed from the configuration.
public setArguments ( array $arguments ) : void
$arguments array
Результат void
    public function setArguments(array $arguments)
    {
        if ($arguments === []) {
            $this->arguments = [];
        } else {
            foreach ($arguments as $argument) {
                if ($argument !== null && $argument instanceof ConfigurationArgument) {
                    $this->setArgument($argument);
                } else {
                    throw new InvalidConfigurationException(sprintf('Only ConfigurationArgument instances are allowed, "%s" given', is_object($argument) ? get_class($argument) : gettype($argument)), 1449217803);
                }
            }
        }
    }

Usage Example

 /**
  * @test
  */
 public function passingAnEmptyArrayToSetArgumentsRemovesAllExistingArguments()
 {
     $someArguments = [1 => new Configuration\ConfigurationArgument(1, 'simple string'), 2 => new Configuration\ConfigurationArgument(2, 'another string')];
     $this->objectConfiguration->setArguments($someArguments);
     $this->assertEquals($someArguments, $this->objectConfiguration->getArguments(), 'The set arguments could not be retrieved again.');
     $this->objectConfiguration->setArguments([]);
     $this->assertEquals([], $this->objectConfiguration->getArguments(), 'The constructor arguments have not been cleared.');
 }