Returns the currently set injection properties of the object
public getProperties ( ) : array |
||
return | array |
/** * @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.'); }
/** * Builds the code necessary to inject setter based dependencies. * * @param Configuration $objectConfiguration (needed to produce helpful exception message) * @return string The built code * @throws ObjectException\UnknownObjectException */ protected function buildPropertyInjectionCode(Configuration $objectConfiguration) { $commands = []; $injectedProperties = []; foreach ($objectConfiguration->getProperties() as $propertyName => $propertyConfiguration) { /* @var $propertyConfiguration ConfigurationProperty */ if ($propertyConfiguration->getAutowiring() === Configuration::AUTOWIRING_MODE_OFF) { continue; } $propertyValue = $propertyConfiguration->getValue(); switch ($propertyConfiguration->getType()) { case ConfigurationProperty::PROPERTY_TYPES_OBJECT: if ($propertyValue instanceof Configuration) { $commands = array_merge($commands, $this->buildPropertyInjectionCodeByConfiguration($objectConfiguration, $propertyName, $propertyValue)); } else { $commands = array_merge($commands, $this->buildPropertyInjectionCodeByString($objectConfiguration, $propertyConfiguration, $propertyName, $propertyValue)); } break; case ConfigurationProperty::PROPERTY_TYPES_STRAIGHTVALUE: if (is_string($propertyValue)) { $preparedSetterArgument = '\'' . str_replace('\'', '\\\'', $propertyValue) . '\''; } elseif (is_array($propertyValue)) { $preparedSetterArgument = var_export($propertyValue, true); } elseif (is_bool($propertyValue)) { $preparedSetterArgument = $propertyValue ? 'TRUE' : 'FALSE'; } else { $preparedSetterArgument = $propertyValue; } $commands[] = 'if (\\Neos\\Utility\\ObjectAccess::setProperty($this, \'' . $propertyName . '\', ' . $preparedSetterArgument . ') === FALSE) { $this->' . $propertyName . ' = ' . $preparedSetterArgument . ';}'; break; case ConfigurationProperty::PROPERTY_TYPES_CONFIGURATION: $configurationType = $propertyValue['type']; if (!in_array($configurationType, $this->configurationManager->getAvailableConfigurationTypes())) { throw new ObjectException\UnknownObjectException('The configuration injection specified for property "' . $propertyName . '" in the object configuration of object "' . $objectConfiguration->getObjectName() . '" refers to the unknown configuration type "' . $configurationType . '".', 1420736211); } $commands = array_merge($commands, $this->buildPropertyInjectionCodeByConfigurationTypeAndPath($objectConfiguration, $propertyName, $configurationType, $propertyValue['path'])); break; } $injectedProperties[] = $propertyName; } if (count($commands) > 0) { $commandString = " " . implode("\n ", $commands) . "\n"; $commandString .= ' $this->Flow_Injected_Properties = ' . var_export($injectedProperties, true) . ";\n"; } else { $commandString = ''; } return $commandString; }