src/Form/Annotation/ElementResolverListener.php
public function resolveComposedTargetObject($e)
    {
        $annotation = $e->getParam('annotation');
        if (!$annotation instanceof ComposedObject) {
            return;
        }

        $formSpec = $e->getParam('formSpec');
        if (!isset($formSpec['object'])) {
            return;
        }

        $metadata = $this->objectManager->getClassMetadata($formSpec['object']);
        $fieldName = $e->getParam('elementSpec')['spec']['name'];

        if ($metadata->hasAssociation($fieldName)) {
            $e->setParam('annotation', new ComposedObject([
                'value' => [
                    'target_object' => $metadata->getAssociationTargetClass($fieldName),
                    'is_collection' => $annotation->isCollection(),
                    'options'       => $annotation->getOptions(),
                ],
            ]));

            return;
        }

        if (!empty($metadata->embeddedClasses[$fieldName])) {
            $class = $metadata->embeddedClasses[$fieldName]['class'];
            if (!is_object($class)) {
                $class = $this->objectManager->getClassMetadata($class)->getName();
            }

            $e->setParam('annotation', new ComposedObject([
                'value' => [
                    'target_object' => $class,
                    'is_collection' => $annotation->isCollection(),
                    'options'       => $annotation->getOptions(),
                ],
            ]));
        }
    }
public function resolveComposedTargetObject($e)
    {
        $annotation = $e->getParam('annotation');
        if (!$annotation instanceof ComposedObject) {
            return;
        }

        $formSpec = $e->getParam('formSpec');
        if (!isset($formSpec['object'])) {
            return;
        }

        $metadata = $this->objectManager->getClassMetadata($formSpec['object']);
        $fieldName = $e->getParam('elementSpec')['spec']['name'];

        if ($metadata->hasAssociation($fieldName)) {
            $e->setParam('annotation', new ComposedObject([
                'value' => [
                    'target_object' => $metadata->getAssociationTargetClass($fieldName),
                    'is_collection' => $annotation->isCollection(),
                    'options'       => $annotation->getOptions(),
                ],
            ]));

            return;
        }

        if (!empty($metadata->embeddedClasses[$fieldName])) {
            $class = $metadata->embeddedClasses[$fieldName]['class'];
            if (!is_object($class)) {
                $class = $this->objectManager->getClassMetadata($class)->getName();
            }

            $e->setParam('annotation', new ComposedObject([
                'value' => [
                    'target_object' => $class,
                    'is_collection' => $annotation->isCollection(),
                    'options'       => $annotation->getOptions(),
                ],
            ]));
        }
    }
public function resolveComposedTargetObject ( $ e ) { $ annotation = $ e -> getParam ( 'annotation' ) ; if ( ! $ annotation instanceof ComposedObject ) { return ; } $ formSpec = $ e -> getParam ( 'formSpec' ) ; if ( ! isset ( $ formSpec [ 'object' ] ) ) { return ; } $ metadata = $ this -> objectManager -> getClassMetadata ( $ formSpec [ 'object' ] ) ; $ fieldName = $ e -> getParam ( 'elementSpec' ) [ 'spec' ] [ 'name' ] ; if ( $ metadata -> hasAssociation ( $ fieldName ) ) { $ e -> setParam ( 'annotation' , new ComposedObject ( [ 'value' => [ 'target_object' => $ metadata -> getAssociationTargetClass ( $ fieldName ) , 'is_collection' => $ annotation -> isCollection ( ) , 'options' => $ annotation -> getOptions ( ) , ] , ] ) ) ; return ; } if ( ! empty ( $ metadata -> embeddedClasses [ $ fieldName ] ) ) { $ class = $ metadata -> embeddedClasses [ $ fieldName ] [ 'class' ] ; if ( ! is_object ( $ class ) ) { $ class = $ this -> objectManager -> getClassMetadata ( $ class ) -> getName ( ) ; } $ e -> setParam ( 'annotation' , new ComposedObject ( [ 'value' => [ 'target_object' => $ class , 'is_collection' => $ annotation -> isCollection ( ) , 'options' => $ annotation -> getOptions ( ) , ] , ] ) ) ; } }
ComposedObject target object resolver

Resolves the interface (specification) into entity object class

@param \Zend\EventManager\EventInterface $e
ComposedObject target object resolver