public function guessDefaultFilter(string $entityFqcn, string $parentEntityProperty, $parentEntity)
    {
        $entityClassMetadata = $this->doctrine->getManagerForClass($entityFqcn)->getClassMetadata($entityFqcn);

        // Required to use getAssociationMappings method
        if (!$entityClassMetadata instanceof ClassMetadataInfo) {
            return [];
        }

        $entityAssociations = $entityClassMetadata->getAssociationMappings();
        $parentEntityFqcn = \get_class($parentEntity);
        foreach ($entityAssociations as $assoc) {
            // If association matches embeddedList relation
            if ($parentEntityFqcn === $assoc['targetEntity'] && $parentEntityProperty === $assoc['inversedBy']) {
                // OneToMany association
                if (isset($assoc['joinColumns']) && 1 === \count($assoc['joinColumns'])) {
                    $assocFieldPart = 'entity.'.$assoc['fieldName'];
                    $assocIdentifierValue = PropertyAccess::createPropertyAccessor()->getValue(
                        $parentEntity, $assoc['joinColumns'][0]['referencedColumnName']
                    );

                    return [$assocFieldPart => $assocIdentifierValue];
                }
                // ManyToMany association
                elseif (isset($assoc['joinTable'])) {
                    $relatedItems = PropertyAccess::createPropertyAccessor()->getValue(
                        $parentEntity, $parentEntityProperty
                    );
                    $itemIds = $relatedItems->map(function ($entity) {
                        return $entity->getId();
                    });

                    return ['entity.id' => $itemIds->toArray()];
                }
            }
        }

        return [];
    }
public function guessDefaultFilter(string $entityFqcn, string $parentEntityProperty, $parentEntity)
    {
        $entityClassMetadata = $this->doctrine->getManagerForClass($entityFqcn)->getClassMetadata($entityFqcn);

        // Required to use getAssociationMappings method
        if (!$entityClassMetadata instanceof ClassMetadataInfo) {
            return [];
        }

        $entityAssociations = $entityClassMetadata->getAssociationMappings();
        $parentEntityFqcn = \get_class($parentEntity);
        foreach ($entityAssociations as $assoc) {
            // If association matches embeddedList relation
            if ($parentEntityFqcn === $assoc['targetEntity'] && $parentEntityProperty === $assoc['inversedBy']) {
                // OneToMany association
                if (isset($assoc['joinColumns']) && 1 === \count($assoc['joinColumns'])) {
                    $assocFieldPart = 'entity.'.$assoc['fieldName'];
                    $assocIdentifierValue = PropertyAccess::createPropertyAccessor()->getValue(
                        $parentEntity, $assoc['joinColumns'][0]['referencedColumnName']
                    );

                    return [$assocFieldPart => $assocIdentifierValue];
                }
                // ManyToMany association
                elseif (isset($assoc['joinTable'])) {
                    $relatedItems = PropertyAccess::createPropertyAccessor()->getValue(
                        $parentEntity, $parentEntityProperty
                    );
                    $itemIds = $relatedItems->map(function ($entity) {
                        return $entity->getId();
                    });

                    return ['entity.id' => $itemIds->toArray()];
                }
            }
        }

        return [];
    }
public function guessDefaultFilter ( string $ entityFqcn , string $ parentEntityProperty , $ parentEntity ) { $ entityClassMetadata = $ this -> doctrine -> getManagerForClass ( $ entityFqcn ) -> getClassMetadata ( $ entityFqcn ) ; // Required to use getAssociationMappings method if ( ! $ entityClassMetadata instanceof ClassMetadataInfo ) { return [ ] ; } $ entityAssociations = $ entityClassMetadata -> getAssociationMappings ( ) ; $ parentEntityFqcn = \ get_class ( $ parentEntity ) ; foreach ( $ entityAssociations as $ assoc ) { // If association matches embeddedList relation if ( $ parentEntityFqcn === $ assoc [ 'targetEntity' ] && $ parentEntityProperty === $ assoc [ 'inversedBy' ] ) { // OneToMany association if ( isset ( $ assoc [ 'joinColumns' ] ) && 1 === \ count ( $ assoc [ 'joinColumns' ] ) ) { $ assocFieldPart = 'entity.' . $ assoc [ 'fieldName' ] ; $ assocIdentifierValue = PropertyAccess :: createPropertyAccessor ( ) -> getValue ( $ parentEntity , $ assoc [ 'joinColumns' ] [ 0 ] [ 'referencedColumnName' ] ) ; return [ $ assocFieldPart => $ assocIdentifierValue ] ; } // ManyToMany association elseif ( isset ( $ assoc [ 'joinTable' ] ) ) { $ relatedItems = PropertyAccess :: createPropertyAccessor ( ) -> getValue ( $ parentEntity , $ parentEntityProperty ) ; $ itemIds = $ relatedItems -> map ( function ( $ entity ) { return $ entity -> getId ( ) ; } ) ; return [ 'entity.id' => $ itemIds -> toArray ( ) ] ; } } } return [ ] ; }
Returns default filter for embeddedList.

@param string $entityFqcn
@param string $parentEntityProperty
@param object $parentEntity

@return array
Returns default filter for embeddedList .