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;
}