protected function buildLifecycleInitializationCode(Configuration $objectConfiguration, $cause)
    {
        $lifecycleInitializationMethodName = $objectConfiguration->getLifecycleInitializationMethodName();
        if (!$this->reflectionService->hasMethod($objectConfiguration->getClassName(), $lifecycleInitializationMethodName)) {
            return '';
        }
        $className = $objectConfiguration->getClassName();
        $code = "\n" . '        $isSameClass = get_class($this) === \'' . $className . '\';';
        if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
            $code .= "\n" . '        $classParents = class_parents($this);';
            $code .= "\n" . '        $classImplements = class_implements($this);';
            $code .= "\n" . '        $isClassProxy = array_search(\'' . $className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n";
            $code .= "\n" . '        if ($isSameClass || $isClassProxy) {' . "\n";
        } else {
            $code .= "\n" . '        if ($isSameClass) {' . "\n";
        }
        $code .= '            $this->' . $lifecycleInitializationMethodName . '(' . $cause . ');' . "\n";
        $code .= '        }' . "\n";
        return $code;
    }
protected function buildLifecycleInitializationCode(Configuration $objectConfiguration, $cause)
    {
        $lifecycleInitializationMethodName = $objectConfiguration->getLifecycleInitializationMethodName();
        if (!$this->reflectionService->hasMethod($objectConfiguration->getClassName(), $lifecycleInitializationMethodName)) {
            return '';
        }
        $className = $objectConfiguration->getClassName();
        $code = "\n" . '        $isSameClass = get_class($this) === \'' . $className . '\';';
        if ($cause === ObjectManagerInterface::INITIALIZATIONCAUSE_RECREATED) {
            $code .= "\n" . '        $classParents = class_parents($this);';
            $code .= "\n" . '        $classImplements = class_implements($this);';
            $code .= "\n" . '        $isClassProxy = array_search(\'' . $className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n";
            $code .= "\n" . '        if ($isSameClass || $isClassProxy) {' . "\n";
        } else {
            $code .= "\n" . '        if ($isSameClass) {' . "\n";
        }
        $code .= '            $this->' . $lifecycleInitializationMethodName . '(' . $cause . ');' . "\n";
        $code .= '        }' . "\n";
        return $code;
    }
protected function buildLifecycleInitializationCode ( Configuration $ objectConfiguration , $ cause ) { $ lifecycleInitializationMethodName = $ objectConfiguration -> getLifecycleInitializationMethodName ( ) ; if ( ! $ this -> reflectionService -> hasMethod ( $ objectConfiguration -> getClassName ( ) , $ lifecycleInitializationMethodName ) ) { return '' ; } $ className = $ objectConfiguration -> getClassName ( ) ; $ code = "\n" . '        $isSameClass = get_class($this) === \'' . $ className . '\';' ; if ( $ cause === ObjectManagerInterface :: INITIALIZATIONCAUSE_RECREATED ) { $ code .= "\n" . '        $classParents = class_parents($this);' ; $ code .= "\n" . '        $classImplements = class_implements($this);' ; $ code .= "\n" . '        $isClassProxy = array_search(\'' . $ className . '\', $classParents) !== false && array_search(\'Doctrine\ORM\Proxy\Proxy\', $classImplements) !== false;' . "\n" ; $ code .= "\n" . '        if ($isSameClass || $isClassProxy) {' . "\n" ; } else { $ code .= "\n" . '        if ($isSameClass) {' . "\n" ; } $ code .= '            $this->' . $ lifecycleInitializationMethodName . '(' . $ cause . ');' . "\n" ; $ code .= '        }' . "\n" ; return $ code ; }
Builds code which calls the lifecycle initialization method, if any.

@param Configuration $objectConfiguration
@param int $cause a ObjectManagerInterface::INITIALIZATIONCAUSE_* constant which is the cause of the initialization command being called.
@return string
Builds code which calls the lifecycle initialization method if any .