@param string $entityType

@return IdentityMap
765135
public function getIdentityMap(string $entityType) : IdentityMap
    {
        if (!isset($this->identityMaps[$entityType])) {
            $this->identityMaps[$entityType] = new IdentityMap($entityType);
        }

        return $this->identityMaps[$entityType];
    }
398735
public function mapper($entity, $entityMap = null)
    {
        if ($entity instanceof Wrapper) {
            throw new MappingException('Tried to instantiate mapper on wrapped Entity');
        }

        $entity = $this->resolveEntityClass($entity);

        $entity = $this->getInverseMorphMap($entity);

        // Return existing mapper instance if exists.
        if (array_key_exists($entity, $this->mappers)) {
            return $this->mappers[$entity];
        } else {
            return $this->buildMapper($entity, $entityMap);
        }
    }
1150434
private function findFieldInstances($entityType, $entityInfo)
    {
        $ret = [];

        // Add field properties, since Drupal does not differenciate entity
        // bundles using different class for different object, we are just
        // gonna give the whole field list
        foreach (field_info_instances($entityType) as $fields) {
            foreach ($fields as $name => $instance) {

                if (isset($ret[$name])) {
                    continue;
                }

                $ret[$name] = $instance;
            }
        }

        return $ret;
    }
193263
public static function generateMap($entities, $entityId, $entityClass)
    {
        $entityMap = [];
        foreach ($entities as $entity) {
            if ($entity instanceof $entityClass) {
                $entityObject = $entity;
            } else {
                $entityObject = new $entityClass;
                foreach ($entity as $key => $value) {
                    $propSetter = 'set'.ucfirst($key);
                    if (method_exists($entityObject, $propSetter)) {
                        $entityObject->$propSetter($value);
                    }
                }
            }

            if (is_null($entityId)) {
                array_push($entityMap, $entityObject);
            } else {
                $propKeyGetter = 'get'.ucfirst($entityId);
                $entityMap[$entityObject->$propKeyGetter()] = $entityObject;
            }
        }

        return $entityMap;
    }
788624
public function getTranslation(
        $entityType,
        $entityId,
        $entityField,
        $locale
    ) {
        $translation = $this
            ->entityTranslationRepository
            ->findOneBy([
                'entityType' => $entityType,
                'entityId' => $entityId,
                'entityField' => $entityField,
                'locale' => $locale,
            ]);

        return $translation instanceof EntityTranslationInterface
            ? $translation->getTranslation()
            : '';
    }
1120258
private function mapBindings($bindingType, array $bindings)
    {
        $res = [];
        foreach ($bindings as $key => $binding) {
            if ($binding instanceof Cursor) {
                $value = [
                    'cursor' => $binding->cursor()
                ];
            } else {
                $value = [
                    'value' => $this->entityMapper->valueObject($binding)
                ];
            }

            if ($bindingType === self::BINDING_NAMED) {
                $res[$key] = $value;
            } else {
                $res[] = $value;
            }
        }

        return $res;
    }
946212
public function registerDoctrineTypeMapping($dbType, $doctrineType)
    {
        if ($this->doctrineTypeMapping === null) {
            $this->initializeAllDoctrineTypeMappings();
        }

        if (! Types\Type::hasType($doctrineType)) {
            throw DBALException::typeNotFound($doctrineType);
        }

        $dbType                             = strtolower($dbType);
        $this->doctrineTypeMapping[$dbType] = $doctrineType;

        $doctrineType = Type::getType($doctrineType);

        if (! $doctrineType->requiresSQLCommentHint($this)) {
            return;
        }

        $this->markDoctrineTypeCommented($doctrineType);
    }
580412
public static function newInstance(EntityInterface $realEntity): self
    {
        $basename = $realEntity->basename();
        $path = $realEntity->path();

        $instance = new static($basename, $path);
        $instance->realEntity = $realEntity;

        return $instance;
    }
512241
public function exportUserTypeEntities($entityId = false) {
        $items = $this->getUserTypeEntities($entityId);
        $export = array();
        foreach ($items as $item) {
            $export[] = $this->prepareExportUserTypeEntity($item, true);
        }
        return $export;
    }
1167520
public function map($formType)
    {
        $this->mapping = array_merge(array($formType => 'string'), $this->mapping);

        return $this->mapping[$formType];
    }
296148
public function getMapping($contentTypeIdentifier, $fieldIdentifier)
    {
        $key = $contentTypeIdentifier . '.' . $fieldIdentifier;

        if (!isset($this->fieldMappings[$key])) {
            return false;
        }

        $identifier = explode('.', $this->fieldMappings[$key]);

        return array(
            'content' => $identifier[0],
            'field' => $identifier[1],
        );
    }
860735
public function buildEntityPostfixByInterfaceName($entityInterfaceName)
    {
        $moduleOptions = $this->getModuleOptions();

        $delimiter = $moduleOptions->getEntitySeparator();

        $stackEntityInterfaceName = explode($delimiter, $entityInterfaceName);

        if (2 !== count($stackEntityInterfaceName)) {
            $this->interfaceNameToEntityPostfix[$entityInterfaceName] = false;
            return false;
        }

        $postfixEntityInterfaceName = array_pop($stackEntityInterfaceName);

        $stackPostfixEntityInterfaceName = explode('\\', $postfixEntityInterfaceName);

        $interfaceName = array_pop($stackPostfixEntityInterfaceName);

        $entityBodyNamePattern = $moduleOptions->getEntityBodyNamePattern();

        $entityBodyNameOutput = [];
        preg_match($entityBodyNamePattern, $interfaceName, $entityBodyNameOutput);

        if (2 !== count($entityBodyNameOutput)) {
            $this->interfaceNameToEntityPostfix[$entityInterfaceName] = false;
            return false;
        }
        $entityBodyName =  array_pop($entityBodyNameOutput);

        $prefix = $moduleOptions->getEntityNamePrefix();
        $postfix = $moduleOptions->getEntityNamePostfix();

        $entityName = $prefix . $entityBodyName . $postfix;

        $stackPostfixEntityInterfaceName[] = $entityName;

        $entityPostfix = implode('\\', $stackPostfixEntityInterfaceName);

        $this->interfaceNameToEntityPostfix[$entityInterfaceName] = $entityPostfix;

        return $this->interfaceNameToEntityPostfix[$entityInterfaceName];
    }
357301
public function getDomainForType($propelType)
    {
        if (!isset($this->schemaDomainMap[$propelType])) {
            throw new EngineException("Cannot map unknown Propel type " . var_export($propelType, true) . " to native database type.");
        }

        return $this->schemaDomainMap[$propelType];
    }
1182274
public void validate(EntityType entityType) {
    validateEntityId(entityType);
    validateEntityLabel(entityType);
    validatePackage(entityType);
    validateExtends(entityType);
    validateOwnAttributes(entityType);

    Map<String, Attribute> ownAllAttrMap =
        stream(entityType.getOwnAllAttributes())
            .collect(toLinkedMap(Attribute::getIdentifier, Function.identity()));

    validateOwnIdAttribute(entityType, ownAllAttrMap);
    validateOwnLabelAttribute(entityType, ownAllAttrMap);
    validateOwnLookupAttributes(entityType, ownAllAttrMap);
    validateLabelAttribute(entityType);
    validateBackend(entityType);
  }
280270
public function getByIds($entityType, array $ids, array $params = [])
    {
        $validIds = array_values(array_unique(array_filter($ids, [__CLASS__, 'isIdValid'])));

        if (count($validIds) === 0) {
            return [];
        }

        $doSortByIds = empty($params['sort']);
        $results = $this->search($entityType, ['_id' => ['$in' => $validIds]], $params);
        if (!$doSortByIds) {
            return $results;
        }

        $flipped = array_flip($validIds);
        foreach ($results as $result) {
            $flipped[$result['_id']] = $result;
        }
        return array_filter(array_values($flipped), function ($result) {
            return is_array($result) && count($result) > 0;
        });

    }
357582
public function setPhoneType(\Sulu\Bundle\ContactBundle\Entity\PhoneType $phoneType)
    {
        $this->phoneType = $phoneType;

        return $this;
    }
67706
public function mapToCollection(CollectionType $collectionType, callable $mapperCallback = null, callable $reverseMapperCallback = null)
    {
        $collectionClass = $collectionType->getCollectionClass();

        if ($collectionClass === TypedCollection::class || $collectionClass === ITypedCollection::class) {
            $collectionFactory = function (array $input) use ($collectionType) {
                return new TypedCollection($collectionType->getElementType(), $input);
            };
        } elseif ($collectionClass === EntityIdCollection::class) {
            $collectionFactory = function (array $input) use ($collectionType) {
                return new EntityIdCollection($input);
            };
        } elseif ($collectionType->isSubsetOf(TypedObject::collectionType())) {
            $objectType = $collectionType->getElementType()->asTypeString();
            $collectionFactory = function (array $input) use ($objectType) {
                /** @var string|TypedObject $objectType */
                return $objectType::collection($input);
            };
        } else {
            throw InvalidArgumentException::format(
                'Invalid collection type supplied to %s: expecting one of (%s), %s given',
                get_class($this) . '::' . __FUNCTION__,
                Debug::formatValues([TypedCollection::class, EntityIdCollection::class, TypedObject::collectionType()->asTypeString()]),
                $collectionType->asTypeString()
            );
        }

        $this->customProcessorCallbacks[] = function (IType $currentType) use (
            $collectionType,
            $collectionFactory,
            $mapperCallback,
            $reverseMapperCallback
        ) {
            return new CustomProcessor(
                $currentType->isNullable() ? $collectionType->nullable() : $collectionType,
                function (array $elements) use ($collectionFactory, $mapperCallback) {
                    $elements = $mapperCallback ? array_map($mapperCallback, $elements) : $elements;

                    return $collectionFactory($elements);
                },
                function (ITypedCollection $collection) use ($collectionType, $reverseMapperCallback) {
                    $elements = [];

                    foreach ($collection as $key => $element) {
                        $elements[$key] = $element;
                    }

                    return $reverseMapperCallback ? array_map($reverseMapperCallback, $elements) : $elements;
                }
            );
        };

        return $this;
    }