src/Bridge/Doctrine/Common/Util/IdentifierManagerTrait.php
private function normalizeIdentifiers($id, ObjectManager $manager, string $resourceClass): array
    {
        $identifierValues = [$id];
        $doctrineClassMetadata = $manager->getClassMetadata($resourceClass);
        $doctrineIdentifierFields = $doctrineClassMetadata->getIdentifier();
        $isOrm = $manager instanceof EntityManagerInterface;
        $isOdm = $manager instanceof DocumentManager;
        $platform = $isOrm ? $manager->getConnection()->getDatabasePlatform() : null;
        $identifiersMap = null;

        if (\count($doctrineIdentifierFields) > 1) {
            $identifiersMap = [];

            // first transform identifiers to a proper key/value array
            foreach (explode(';', (string) $id) as $identifier) {
                if (!$identifier) {
                    continue;
                }

                $identifierPair = explode('=', $identifier);
                $identifiersMap[$identifierPair[0]] = $identifierPair[1];
            }
        }

        $identifiers = [];
        $i = 0;

        foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) {
            $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName);

            if (!$propertyMetadata->isIdentifier()) {
                continue;
            }

            $identifier = null === $identifiersMap ? $identifierValues[$i] ?? null : $identifiersMap[$propertyName] ?? null;
            if (null === $identifier) {
                throw new PropertyNotFoundException(sprintf('Invalid identifier "%s", "%s" was not found.', $id, $propertyName));
            }

            $doctrineTypeName = $doctrineClassMetadata->getTypeOfField($propertyName);

            if ($isOrm && null !== $doctrineTypeName && DBALType::hasType($doctrineTypeName)) {
                $identifier = DBALType::getType($doctrineTypeName)->convertToPHPValue($identifier, $platform);
            }
            if ($isOdm && null !== $doctrineTypeName && MongoDbType::hasType($doctrineTypeName)) {
                $identifier = MongoDbType::getType($doctrineTypeName)->convertToPHPValue($identifier);
            }

            $identifiers[$propertyName] = $identifier;
            ++$i;
        }

        return $identifiers;
    }
private function normalizeIdentifiers($id, ObjectManager $manager, string $resourceClass): array
    {
        $identifierValues = [$id];
        $doctrineClassMetadata = $manager->getClassMetadata($resourceClass);
        $doctrineIdentifierFields = $doctrineClassMetadata->getIdentifier();
        $isOrm = $manager instanceof EntityManagerInterface;
        $isOdm = $manager instanceof DocumentManager;
        $platform = $isOrm ? $manager->getConnection()->getDatabasePlatform() : null;
        $identifiersMap = null;

        if (\count($doctrineIdentifierFields) > 1) {
            $identifiersMap = [];

            // first transform identifiers to a proper key/value array
            foreach (explode(';', (string) $id) as $identifier) {
                if (!$identifier) {
                    continue;
                }

                $identifierPair = explode('=', $identifier);
                $identifiersMap[$identifierPair[0]] = $identifierPair[1];
            }
        }

        $identifiers = [];
        $i = 0;

        foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) {
            $propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName);

            if (!$propertyMetadata->isIdentifier()) {
                continue;
            }

            $identifier = null === $identifiersMap ? $identifierValues[$i] ?? null : $identifiersMap[$propertyName] ?? null;
            if (null === $identifier) {
                throw new PropertyNotFoundException(sprintf('Invalid identifier "%s", "%s" was not found.', $id, $propertyName));
            }

            $doctrineTypeName = $doctrineClassMetadata->getTypeOfField($propertyName);

            if ($isOrm && null !== $doctrineTypeName && DBALType::hasType($doctrineTypeName)) {
                $identifier = DBALType::getType($doctrineTypeName)->convertToPHPValue($identifier, $platform);
            }
            if ($isOdm && null !== $doctrineTypeName && MongoDbType::hasType($doctrineTypeName)) {
                $identifier = MongoDbType::getType($doctrineTypeName)->convertToPHPValue($identifier);
            }

            $identifiers[$propertyName] = $identifier;
            ++$i;
        }

        return $identifiers;
    }
private function normalizeIdentifiers ( $ id , ObjectManager $ manager , string $ resourceClass ) : array { $ identifierValues = [ $ id ] ; $ doctrineClassMetadata = $ manager -> getClassMetadata ( $ resourceClass ) ; $ doctrineIdentifierFields = $ doctrineClassMetadata -> getIdentifier ( ) ; $ isOrm = $ manager instanceof EntityManagerInterface ; $ isOdm = $ manager instanceof DocumentManager ; $ platform = $ isOrm ? $ manager -> getConnection ( ) -> getDatabasePlatform ( ) : null ; $ identifiersMap = null ; if ( \ count ( $ doctrineIdentifierFields ) > 1 ) { $ identifiersMap = [ ] ; // first transform identifiers to a proper key/value array foreach ( explode ( ';' , ( string ) $ id ) as $ identifier ) { if ( ! $ identifier ) { continue ; } $ identifierPair = explode ( '=' , $ identifier ) ; $ identifiersMap [ $ identifierPair [ 0 ] ] = $ identifierPair [ 1 ] ; } } $ identifiers = [ ] ; $ i = 0 ; foreach ( $ this -> propertyNameCollectionFactory -> create ( $ resourceClass ) as $ propertyName ) { $ propertyMetadata = $ this -> propertyMetadataFactory -> create ( $ resourceClass , $ propertyName ) ; if ( ! $ propertyMetadata -> isIdentifier ( ) ) { continue ; } $ identifier = null === $ identifiersMap ? $ identifierValues [ $ i ] ?? null : $ identifiersMap [ $ propertyName ] ?? null ; if ( null === $ identifier ) { throw new PropertyNotFoundException ( sprintf ( 'Invalid identifier "%s", "%s" was not found.' , $ id , $ propertyName ) ) ; } $ doctrineTypeName = $ doctrineClassMetadata -> getTypeOfField ( $ propertyName ) ; if ( $ isOrm && null !== $ doctrineTypeName && DBALType :: hasType ( $ doctrineTypeName ) ) { $ identifier = DBALType :: getType ( $ doctrineTypeName ) -> convertToPHPValue ( $ identifier , $ platform ) ; } if ( $ isOdm && null !== $ doctrineTypeName && MongoDbType :: hasType ( $ doctrineTypeName ) ) { $ identifier = MongoDbType :: getType ( $ doctrineTypeName ) -> convertToPHPValue ( $ identifier ) ; } $ identifiers [ $ propertyName ] = $ identifier ; ++ $ i ; } return $ identifiers ; }
Transform and check the identifier, composite or not.

@param int|string $id

@throws PropertyNotFoundException
Transform and check the identifier composite or not .