Defines the entity mapper

@param MapperDefinition $map

@return void
13276
protected function define(MapperDefinition $map)
    {
        $map->type(BlogArticleComment::class);

        $map->toTable('article_comments');

        $map->idToPrimaryKey('id');

        $map->column($map->getOrm()->getNamespace() . 'article_id')->asUnsignedInt();
        $map->relation(BlogArticleComment::ARTICLE)
            ->to(BlogArticle::class)
            ->manyToOne()
            ->withBidirectionalRelation(BlogArticle::COMMENTS)
            ->withRelatedIdAs($map->getOrm()->getNamespace() . 'article_id');

        $map->property(BlogArticleComment::AUTHOR_NAME)->to('author_name')->asVarchar(255);

        $map->embedded(BlogArticleComment::AUTHOR_EMAIL)
            ->using(new EmailAddressMapper('author_email'));

        $map->property(BlogArticleComment::CONTENT)->to('content')->asText();

        $map->embedded(BlogArticleComment::POSTED_AT)
            ->using(new DateTimeMapper('posted_at'));

        MetadataMapper::mapMetadataToJsonColumn($map, 'metadata');
    }
103433
protected function defineRelation(callable $mapperLoader)
    {
        call_user_func($this->callback, function (IObjectMapper $parentMapper) use ($mapperLoader) {
            /** @var IEmbeddedObjectMapper $mapper */
            $mapper = $mapperLoader($parentMapper);
            return $this->prefix ? $mapper->withColumnsPrefixedBy($this->prefix) : $mapper;
        }, $this->issetColumnName, $this->isUnique);
    }
991760
public function mapManyToMany(array $mapping)
    {
        $mapping['type'] = self::MANY_TO_MANY;
        $mapping = $this->_validateAndCompleteManyToManyMapping($mapping);
        $this->_storeAssociationMapping($mapping);
    }
1356925
public function mapOneToMany(array $mapping)
    {
        $mapping['type'] = self::ONE_TO_MANY;
        $mapping = $this->_validateAndCompleteOneToManyMapping($mapping);
        $this->_storeAssociationMapping($mapping);
    }
331594
protected function define(MapperDefinition $map)
    {
        $map->type(AnalyticsDriverConfig::class);
        $map->toTable('analytics');

        $map->idToPrimaryKey('id');

        $map->property(AnalyticsDriverConfig::DRIVER_NAME)->to('driver')->asVarchar(255);
        $map->property(AnalyticsDriverConfig::OPTIONS)
            ->mappedVia(function (FormObject $options) : string {
                $values            = $this->transformFilesToArrays($options->unprocess($options->getInitialValues()));
                $values['__class'] = get_class($options);

                return json_encode($values);
            }, function (string $json) : FormObject {
                $values = $this->restoreFilesFromStrings(json_decode($json, true));

                return $values['__class']::build(array_diff_key($values, ['__class' => true]));
            })
            ->to('options')
            ->asText();
    }
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);
        }
    }
460161
protected function defineEntity(ClassDefinition $class)
    {
        $class->property($this->question)->asString();

        $class->property($this->answer)->asObject(Html::class);

        $class->property($this->orderToDisplay)->asInt();

        $class->property($this->updatedAt)->asObject(DateTime::class);
        
        $class->property($this->createdAt)->asObject(DateTime::class);
    }
605405
public function persist(PersistenceContext $context, ParentChildrenMap $map)
    {
        if ($map->hasAnyParentsWithPrimaryKeys()) {
            $this->mode->syncInvalidatedRelationsQuery(
                $context,
                $this->childrenTable,
                $this->foreignKeyToParent,
                $this->getInvalidatedRelationExpr($map)
            );
        }

        $this->insertRelated($context, $map);
    }
568412
public function setDiscriminatorMap(array $map)
    {
        foreach ($map as $value => $className) {
            $this->discriminatorMap[$value] = $className;
            if ($this->name == $className) {
                $this->discriminatorValue = $value;
            } else {
                if (!class_exists($className)) {
                    throw MappingException::invalidClassInDiscriminatorMap($className, $this->name);
                }
                if (is_subclass_of($className, $this->name)) {
                    $this->subClassNames[] = $className;
                }
            }
        }
    }
51183
protected function define(MapperDefinition $map)
    {
        $map->type(BlogAuthor::class);

        $map->toTable('authors');

        $map->idToPrimaryKey('id');

        $map->property(BlogAuthor::NAME)->to('name')->asVarchar(255);

        $map->property(BlogAuthor::ROLE)->to('role')->asVarchar(255);

        $map->property(BlogAuthor::SLUG)->to('slug')->unique()->asVarchar(255);

        $map->embedded(BlogAuthor::BIO)
            ->using(new HtmlMapper('bio'));

        $map->relation(BlogAuthor::ARTICLES)
            ->to(BlogArticle::class)
            ->toMany()
            ->identifying()
            ->withBidirectionalRelation(BlogArticle::AUTHOR)
            ->withParentIdAs($map->getOrm()->getNamespace() . 'author_id');

        MetadataMapper::mapMetadataToJsonColumn($map, 'metadata');
    }
1015013
public function encodeMap(Map $map, Encoder $encoder)
    {
        $output = $encoder->getOutput();
        $hash   = spl_object_hash($map);

        if (!isset($this->initialized[$hash])) {
            $output->prepend(
                sprintf(
                    '%s = L.map(%s);',
                    $encoder->encodeReference($map),
                    $encoder->encodeArguments(array($map->getElementId(), $map->getOptions()))
                )
            );

            $this->initialized[$hash] = true;
        } else {
            foreach ($map->getControls() as $control) {
                $encoder->encodeReference($control);
            }

            foreach ($map->getLayers() as $layer) {
                $encoder->encodeReference($layer);
            }

            $output->append($this->encodeMethodCalls($map->getMethodCalls(), $encoder));
        }
    }
157978
public function persist(PersistenceContext $context, ParentChildMap $map)
    {
        /** @var Row[] $parentRows */
        $parentRows = [];
        /** @var object[] $children */
        $children = [];

        foreach ($map->getItems() as $key => $item) {
            $parentRow = $item->getParent();

            $hasChild = (bool)$item->getChild();
            if ($hasChild) {
                $parentRows[$key] = $parentRow;
                $children[$key]   = $item->getChild();
            }

            if ($this->objectIssetColumnName && !$this->isWithinValueObject) {
                $parentRow->setColumn($this->objectIssetColumnName, $hasChild);
            }
        }

        $this->disableLazyLoadingForRelations(function () use ($context, $children, $parentRows) {
            $this->mapper->persistAllToRows($context, $children, $parentRows);
        });
    }
483744
protected function validateAndCompleteEntity($entityIdentifier, $entityDefinition)
	{
		if(!isset($entityDefinition['label']))
		{
			throw MappingException::requiredMapping($this->itemClass, 'label', $entityIdentifier);
		}
		elseif(!settype($entityDefinition['label'], 'string'))
		{
			throw MappingException::invalidMappingType($this->itemClass, 'label', 'string', $entityIdentifier);
		}
		else
		{
			$this->entityLabels[$entityIdentifier] = $entityDefinition['label'];
		}

		if(!isset($entityDefinition['entityClass']))
		{
			throw MappingException::requiredMapping($this->itemClass, 'entityClass', $entityIdentifier);
		}
		elseif(!settype($entityDefinition['entityClass'], 'string'))
		{
			throw MappingException::invalidMappingType($this->itemClass, 'entityClass', 'string', $entityIdentifier);
		}
		else
		{
			$this->entityClasses[$entityIdentifier] = $entityDefinition['entityClass'];
		}
	}
732302
protected function define(MapperDefinition $map)
    {
        $map->type(StreetAddressWithLatLng::class);

        $map->property(StreetAddressWithLatLng::ADDRESS)
                ->to($this->addressColumnName)->asVarchar(StreetAddress::MAX_LENGTH);

        $map->embedded(StreetAddressWithLatLng::LAT_LNG)
                ->using(new LatLngMapper($this->latColumnName, $this->lngColumnName));
    }
1057733
protected function addMappingNode(
        string $nodeName,
        string $entityClass,
        string $entityMappingFile,
        string $entityManager,
        bool $entityEnabled
    ): NodeDefinition {
        $builder = new TreeBuilder();
        $node = $builder->root($nodeName);
        $node
            ->treatFalseLike([
                'enabled' => false,
            ])
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('class')
                    ->defaultValue($entityClass)
                    ->cannotBeEmpty()
                ->end()
                ->scalarNode('mapping_file')
                    ->defaultValue($entityMappingFile)
                    ->cannotBeEmpty()
                ->end()
                ->scalarNode('manager')
                    ->defaultValue($entityManager)
                    ->cannotBeEmpty()
                ->end()
                ->booleanNode('enabled')
                    ->defaultValue($entityEnabled)
                ->end()
            ->end()
        ->end();

        return $node;
    }
1212351
public function register($entity, $entityMap = null)
    {
        // If an object is provider, get the class name from it
        if (!is_string($entity)) {
            $entity = get_class($entity);
        }

        if ($this->isRegisteredEntity($entity)) {
            throw new MappingException("Entity $entity is already registered.");
        }

        if (!class_exists($entity)) {
            throw new MappingException("Class $entity does not exists");
        }

        if ($entityMap === null) {
            $entityMap = $this->getEntityMapInstanceFor($entity);
        }

        if (is_string($entityMap)) {
            $entityMap = new $entityMap();
        }

        if (!$entityMap instanceof EntityMap) {
            throw new MappingException(get_class($entityMap).' must be an instance of EntityMap.');
        }

        $entityMap->setClass($entity);

        $this->entityClasses[$entity] = $entityMap;
    }
1315225
private function registerLocator(
        ContainerBuilder $container,
        EntityMapping $entityMapping
    ) {
        /**
         * Locator.
         */
        $locatorId = 'simple_doctrine_mapping.locator.' . $entityMapping->getUniqueIdentifier();
        $locator = new Definition('Mmoreram\SimpleDoctrineMapping\Locator\SimpleDoctrineMappingLocator');
        $locator->setPublic(false);
        $locator->setArguments([
            $entityMapping->getEntityNamespace(),
            [$entityMapping->getEntityMappingFilePath()],
        ]);
        $locator->setConfigurator([
            new Reference('simple_doctrine_mapping.locator_configurator'),
            'configure',
        ]);
        $container->setDefinition($locatorId, $locator);
    }