public function build()
    {
        $this->objectConfigurations = $this->objectManager->getObjectConfigurations();

        foreach ($this->objectConfigurations as $objectName => $objectConfiguration) {
            $className = $objectConfiguration->getClassName();
            if ($className === '' || $this->compiler->hasCacheEntryForClass($className) === true) {
                continue;
            }

            if ($objectName !== $className || $this->reflectionService->isClassAbstract($className)) {
                continue;
            }
            $proxyClass = $this->compiler->getProxyClass($className);
            if ($proxyClass === false) {
                continue;
            }
            $this->logger->debug('Building DI proxy for "' . $className . '".');

            $constructorPreCode = '';
            $constructorPostCode = '';

            $constructorPreCode .= $this->buildSetInstanceCode($objectConfiguration);
            $constructorPreCode .= $this->buildConstructorInjectionCode($objectConfiguration);

            $setRelatedEntitiesCode = '';
            if (!$this->reflectionService->hasMethod($className, '__sleep')) {
                $proxyClass->addTraits(['\\' . ObjectSerializationTrait::class]);
                $sleepMethod = $proxyClass->getMethod('__sleep');
                $sleepMethod->addPostParentCallCode($this->buildSerializeRelatedEntitiesCode($objectConfiguration));

                $setRelatedEntitiesCode = "\n        " . '$this->Flow_setRelatedEntities();' . "\n";
            }

            $wakeupMethod = $proxyClass->getMethod('__wakeup');
            $wakeupMethod->addPreParentCallCode($this->buildSetInstanceCode($objectConfiguration));
            $wakeupMethod->addPreParentCallCode($setRelatedEntitiesCode);
            $wakeupMethod->addPostParentCallCode($this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));
            $wakeupMethod->addPostParentCallCode($this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));

            $injectPropertiesCode = $this->buildPropertyInjectionCode($objectConfiguration);
            if ($injectPropertiesCode !== '') {
                $proxyClass->addTraits(['\\' . PropertyInjectionTrait::class]);
                $proxyClass->getMethod('Flow_Proxy_injectProperties')->addPreParentCallCode($injectPropertiesCode);
                $proxyClass->getMethod('Flow_Proxy_injectProperties')->overrideMethodVisibility('private');
                $wakeupMethod->addPreParentCallCode("        \$this->Flow_Proxy_injectProperties();\n");

                $constructorPostCode .= '        if (\'' . $className . '\' === get_class($this)) {' . "\n";
                $constructorPostCode .= '            $this->Flow_Proxy_injectProperties();' . "\n";
                $constructorPostCode .= '        }' . "\n";
            }

            $constructorPostCode .= $this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
            $constructorPostCode .= $this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);

            $constructor = $proxyClass->getConstructor();
            $constructor->addPreParentCallCode($constructorPreCode);
            $constructor->addPostParentCallCode($constructorPostCode);

            if ($this->objectManager->getContext()->isProduction()) {
                $this->compileStaticMethods($className, $proxyClass);
            }
        }
    }
public function build()
    {
        $this->objectConfigurations = $this->objectManager->getObjectConfigurations();

        foreach ($this->objectConfigurations as $objectName => $objectConfiguration) {
            $className = $objectConfiguration->getClassName();
            if ($className === '' || $this->compiler->hasCacheEntryForClass($className) === true) {
                continue;
            }

            if ($objectName !== $className || $this->reflectionService->isClassAbstract($className)) {
                continue;
            }
            $proxyClass = $this->compiler->getProxyClass($className);
            if ($proxyClass === false) {
                continue;
            }
            $this->logger->debug('Building DI proxy for "' . $className . '".');

            $constructorPreCode = '';
            $constructorPostCode = '';

            $constructorPreCode .= $this->buildSetInstanceCode($objectConfiguration);
            $constructorPreCode .= $this->buildConstructorInjectionCode($objectConfiguration);

            $setRelatedEntitiesCode = '';
            if (!$this->reflectionService->hasMethod($className, '__sleep')) {
                $proxyClass->addTraits(['\\' . ObjectSerializationTrait::class]);
                $sleepMethod = $proxyClass->getMethod('__sleep');
                $sleepMethod->addPostParentCallCode($this->buildSerializeRelatedEntitiesCode($objectConfiguration));

                $setRelatedEntitiesCode = "\n        " . '$this->Flow_setRelatedEntities();' . "\n";
            }

            $wakeupMethod = $proxyClass->getMethod('__wakeup');
            $wakeupMethod->addPreParentCallCode($this->buildSetInstanceCode($objectConfiguration));
            $wakeupMethod->addPreParentCallCode($setRelatedEntitiesCode);
            $wakeupMethod->addPostParentCallCode($this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));
            $wakeupMethod->addPostParentCallCode($this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED));

            $injectPropertiesCode = $this->buildPropertyInjectionCode($objectConfiguration);
            if ($injectPropertiesCode !== '') {
                $proxyClass->addTraits(['\\' . PropertyInjectionTrait::class]);
                $proxyClass->getMethod('Flow_Proxy_injectProperties')->addPreParentCallCode($injectPropertiesCode);
                $proxyClass->getMethod('Flow_Proxy_injectProperties')->overrideMethodVisibility('private');
                $wakeupMethod->addPreParentCallCode("        \$this->Flow_Proxy_injectProperties();\n");

                $constructorPostCode .= '        if (\'' . $className . '\' === get_class($this)) {' . "\n";
                $constructorPostCode .= '            $this->Flow_Proxy_injectProperties();' . "\n";
                $constructorPostCode .= '        }' . "\n";
            }

            $constructorPostCode .= $this->buildLifecycleInitializationCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
            $constructorPostCode .= $this->buildLifecycleShutdownCode($objectConfiguration, ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);

            $constructor = $proxyClass->getConstructor();
            $constructor->addPreParentCallCode($constructorPreCode);
            $constructor->addPostParentCallCode($constructorPostCode);

            if ($this->objectManager->getContext()->isProduction()) {
                $this->compileStaticMethods($className, $proxyClass);
            }
        }
    }
public function build ( ) { $ this -> objectConfigurations = $ this -> objectManager -> getObjectConfigurations ( ) ; foreach ( $ this -> objectConfigurations as $ objectName => $ objectConfiguration ) { $ className = $ objectConfiguration -> getClassName ( ) ; if ( $ className === '' || $ this -> compiler -> hasCacheEntryForClass ( $ className ) === true ) { continue ; } if ( $ objectName !== $ className || $ this -> reflectionService -> isClassAbstract ( $ className ) ) { continue ; } $ proxyClass = $ this -> compiler -> getProxyClass ( $ className ) ; if ( $ proxyClass === false ) { continue ; } $ this -> logger -> debug ( 'Building DI proxy for "' . $ className . '".' ) ; $ constructorPreCode = '' ; $ constructorPostCode = '' ; $ constructorPreCode .= $ this -> buildSetInstanceCode ( $ objectConfiguration ) ; $ constructorPreCode .= $ this -> buildConstructorInjectionCode ( $ objectConfiguration ) ; $ setRelatedEntitiesCode = '' ; if ( ! $ this -> reflectionService -> hasMethod ( $ className , '__sleep' ) ) { $ proxyClass -> addTraits ( [ '\\' . ObjectSerializationTrait :: class ] ) ; $ sleepMethod = $ proxyClass -> getMethod ( '__sleep' ) ; $ sleepMethod -> addPostParentCallCode ( $ this -> buildSerializeRelatedEntitiesCode ( $ objectConfiguration ) ) ; $ setRelatedEntitiesCode = "\n        " . '$this->Flow_setRelatedEntities();' . "\n" ; } $ wakeupMethod = $ proxyClass -> getMethod ( '__wakeup' ) ; $ wakeupMethod -> addPreParentCallCode ( $ this -> buildSetInstanceCode ( $ objectConfiguration ) ) ; $ wakeupMethod -> addPreParentCallCode ( $ setRelatedEntitiesCode ) ; $ wakeupMethod -> addPostParentCallCode ( $ this -> buildLifecycleInitializationCode ( $ objectConfiguration , ObjectManagerInterface :: INITIALIZATIONCAUSE_RECREATED ) ) ; $ wakeupMethod -> addPostParentCallCode ( $ this -> buildLifecycleShutdownCode ( $ objectConfiguration , ObjectManagerInterface :: INITIALIZATIONCAUSE_RECREATED ) ) ; $ injectPropertiesCode = $ this -> buildPropertyInjectionCode ( $ objectConfiguration ) ; if ( $ injectPropertiesCode !== '' ) { $ proxyClass -> addTraits ( [ '\\' . PropertyInjectionTrait :: class ] ) ; $ proxyClass -> getMethod ( 'Flow_Proxy_injectProperties' ) -> addPreParentCallCode ( $ injectPropertiesCode ) ; $ proxyClass -> getMethod ( 'Flow_Proxy_injectProperties' ) -> overrideMethodVisibility ( 'private' ) ; $ wakeupMethod -> addPreParentCallCode ( "        \$this->Flow_Proxy_injectProperties();\n" ) ; $ constructorPostCode .= '        if (\'' . $ className . '\' === get_class($this)) {' . "\n" ; $ constructorPostCode .= '            $this->Flow_Proxy_injectProperties();' . "\n" ; $ constructorPostCode .= '        }' . "\n" ; } $ constructorPostCode .= $ this -> buildLifecycleInitializationCode ( $ objectConfiguration , ObjectManagerInterface :: INITIALIZATIONCAUSE_CREATED ) ; $ constructorPostCode .= $ this -> buildLifecycleShutdownCode ( $ objectConfiguration , ObjectManagerInterface :: INITIALIZATIONCAUSE_CREATED ) ; $ constructor = $ proxyClass -> getConstructor ( ) ; $ constructor -> addPreParentCallCode ( $ constructorPreCode ) ; $ constructor -> addPostParentCallCode ( $ constructorPostCode ) ; if ( $ this -> objectManager -> getContext ( ) -> isProduction ( ) ) { $ this -> compileStaticMethods ( $ className , $ proxyClass ) ; } } }
Analyzes the Object Configuration provided by the compiler and builds the necessary PHP code for the proxy classes
to realize dependency injection.

@return void
Analyzes the Object Configuration provided by the compiler and builds the necessary PHP code for the proxy classes to realize dependency injection .