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;
    }
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;
    }
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 ; }
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
Builds the code necessary to inject setter based dependencies .