Neos\Flow\ObjectManagement\Configuration\Configuration::setProperties PHP Method

setProperties() public method

Setter function for injection properties. If an empty array is passed to this method, all (possibly) defined properties are removed from the configuration.
public setProperties ( array $properties ) : void
$properties array Array of ConfigurationProperty
return void
    public function setProperties(array $properties)
    {
        if ($properties === []) {
            $this->properties = [];
        } else {
            foreach ($properties as $value) {
                if ($value instanceof ConfigurationProperty) {
                    $this->setProperty($value);
                } else {
                    throw new InvalidConfigurationException(sprintf('Only ConfigurationProperty instances are allowed, "%s" given', is_object($value) ? get_class($value) : gettype($value)), 1449217567);
                }
            }
        }
    }

Usage Example

 /**
  * @test
  */
 public function passingAnEmptyArrayToSetPropertiesRemovesAllExistingproperties()
 {
     $someProperties = ['prop1' => new Configuration\ConfigurationProperty('prop1', 'simple string'), 'prop2' => new Configuration\ConfigurationProperty('prop2', 'another string')];
     $this->objectConfiguration->setProperties($someProperties);
     $this->assertEquals($someProperties, $this->objectConfiguration->getProperties(), 'The set properties could not be retrieved again.');
     $this->objectConfiguration->setProperties([]);
     $this->assertEquals([], $this->objectConfiguration->getProperties(), 'The properties have not been cleared.');
 }