@param ElementVersionMappedField $mappedField

@return $this
768925
public function addMappedField(ElementVersionMappedField $mappedField)
    {
        if (!$this->mappedFields->containsKey($mappedField->getLanguage())) {
            $this->mappedFields->set($mappedField->getLanguage(), $mappedField);
            $mappedField->setElementVersion($this);
        }

        return $this;
    }
428690
public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context)
    {
        $this->gateway->deleteFieldData($versionInfo, [$field->id]);
        if (!empty($field->value->externalData)) {
            $externalData = $field->value->externalData;
            foreach ($externalData as $key => $tag) {
                if (!isset($tag['id'])) {
                    try {
                        $createdTag = $this->createTag($tag);
                        $field->value->externalData[$key]['id'] = $createdTag->id;
                    } catch (UnauthorizedException $e) {
                        // If users cannot create tags, just remove it from
                        // the list of tags to be created
                        unset($field->value->externalData[$key]);
                    }
                }
            }

            $this->gateway->storeFieldData($versionInfo, $field);
        }
    }
1334303
public function mapTree(array $nodes, array $mappedNodes = []) {
        if (!$mappedNodes) {
            return $nodes;
        }

        $tree = [];
        $pk = $this->getRepository()->getPrimaryKey();

        foreach ($nodes as $node) {
            $id = $node[$pk];

            if (isset($mappedNodes[$id])) {
                $node[$this->getConfig('treeField') ?: 'Nodes'] = $this->mapTree($mappedNodes[$id], $mappedNodes);
            }

            $tree[] = $node;
        }

        return $tree;
    }
462926
public function mapSafariVersion(string $detectedVersion): string
    {
        $regularVersions = [
            3.0,
            3.1,
            3.2,
            4.0,
            4.1,
            4.2,
            4.3,
            4.4,
            5.0,
            5.1,
            5.2,
            6.0,
            6.1,
            6.2,
            7.0,
            7.1,
            8.0,
            8.1,
            9.0,
            9.1,
            10.0,
            10.1,
            11.0,
            12.0,
        ];

        if (in_array($detectedVersion, $regularVersions)) {
            return $detectedVersion;
        }

        $versions = [
            '14600' => '12.0',
            '13600' => '11.0',
            '12600' => '10.0',
            '11600' => '9.1',
            '10500' => '8.0',
            '9500' => '7.0',
            '8500' => '6.0',
            '7500' => '5.1',
            '6500' => '5.0',
            '4500' => '4.0',
            '600' => '5.0',
            '500' => '4.0',
            '400' => '3.0',
        ];

        foreach ($versions as $engineVersion => $osVersion) {
            if (version_compare($detectedVersion, (string) $engineVersion, '>=')) {
                return $osVersion;
            }
        }

        return '0';
    }
85979
public ConversionHandler from(MappedField sourceMappedField){
		this.sourceField = sourceMappedField.getValue();
		placeholders.put(sourceTypePattern, sourceField.getType().getName());
		placeholders.put(sourceNamePattern, sourceField.getName());
		placeholders.put(sourceGetPattern, sourceMappedField.getMethod());
		placeholders.put(sourceSetPattern, sourceMappedField.setMethod());
		return this;
	}
1005423
public static void mapping(String mappedFieldName, String mappedClassName, String targetClassName){
		throw new MappingErrorException(MSG.INSTANCE.message(mappingErrorException3,mappedFieldName,mappedClassName,targetClassName));
	}
693135
public function saveField (MapField $field, ElementInterface $owner)
	{
		if ($owner instanceof MapElement)
			return;

		/** @var MapElement $map */
		$map = $owner->getFieldValue($field->handle);

		$map->fieldId     = $field->id;
		$map->ownerId     = $owner->id;
		$map->ownerSiteId = $owner->siteId;

		\Craft::$app->elements->saveElement($map, true, true);
	}
1264887
protected function storeNewFieldData(VersionInfo $versionInfo, Field $field)
    {
        $connection = $this->getConnection();

        $insertQuery = $connection->createInsertQuery();
        $insertQuery->insertInto($connection->quoteTable('ezgmaplocation'))
            ->set(
                $connection->quoteColumn('latitude'),
                $insertQuery->bindValue($field->value->externalData['latitude'])
            )->set(
                $connection->quoteColumn('longitude'),
                $insertQuery->bindValue($field->value->externalData['longitude'])
            )->set(
                $connection->quoteColumn('address'),
                $insertQuery->bindValue($field->value->externalData['address'])
            )->set(
                $connection->quoteColumn('contentobject_attribute_id'),
                $insertQuery->bindValue($field->id, null, \PDO::PARAM_INT)
            )->set(
                $connection->quoteColumn('contentobject_version'),
                $insertQuery->bindValue($versionInfo->versionNo, null, \PDO::PARAM_INT)
            );

        $insertQuery->prepare()->execute();
    }
388660
protected function storeNewFieldData(VersionInfo $versionInfo, Field $field)
    {
        $insertQuery = $this->connection->createQueryBuilder();
        $insertQuery
            ->insert($this->connection->quoteIdentifier(self::MAP_LOCATION_TABLE))
            ->values([
                'latitude' => ':latitude',
                'longitude' => ':longitude',
                'address' => ':address',
                'contentobject_attribute_id' => ':fieldId',
                'contentobject_version' => ':versionNo',
            ])
            ->setParameter(':latitude', $field->value->externalData['latitude'])
            ->setParameter(':longitude', $field->value->externalData['longitude'])
            ->setParameter(':address', $field->value->externalData['address'])
            ->setParameter(':fieldId', $field->id)
            ->setParameter(':versionNo', $versionInfo->versionNo)
        ;

        $insertQuery->execute();
    }
835064
protected function createNewField(Field $field, Content $content)
    {
        $field->versionNo = $content->versionInfo->versionNo;

        $field->id = $this->contentGateway->insertNewField(
            $content,
            $field,
            $this->mapper->convertToStorageValue($field)
        );

        // If the storage handler returns true, it means that $field value has been modified
        // So we need to update it in order to store those modifications
        // Field converter is called once again via the Mapper
        if ($this->storageHandler->storeFieldData($content->versionInfo, $field) === true) {
            $this->contentGateway->updateField(
                $field,
                $this->mapper->convertToStorageValue($field)
            );
        }
    }
1031192
public function map($obj, $mappingName, $context = [])
    {
        if (!$mappingName || !array_key_exists($mappingName, $this->mappings)) {
            throw new \InvalidArgumentException(sprintf('Invalid mapping name "%s"', $mappingName));
        }

        if (empty($obj) && !$this->shouldAcceptEmptyValues($context, $obj)) {
            return $obj;
        }

        $mapping = @$this->mappings[$mappingName];

        return $this->resolve($mapping, $obj, $context);
    }
855972
public function createHashValuesByElementVersion(ElementVersion $elementVersion, $language)
    {
        $elementStructure = $this->elementService->findElementStructure($elementVersion, $language);

        $eid = $elementVersion->getElement()->getEid();
        $elementtypeId = $elementVersion->getElement()->getElementtypeId();
        $elementtypeVersion = $elementVersion->getElementtypeVersion();

        // TODO: meta resolver
        $meta = []; //$this->_db->fetchCol($selectMeta);
        sort($meta);

        $rii = new \RecursiveIteratorIterator($elementStructure->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
        $content = [];
        foreach ($elementStructure->getValues() as $valueIndex => $value) {
            $key = sprintf('%s__%s__%s', $elementStructure->getDsId(), $elementStructure->getSort(), $value->getDsId());
            $content[$key] = $value->getValue();
        }
        foreach ($rii as $structureIndex => $structure) {
            foreach ($structure->getValues() as $valueIndex => $value) {
                $key = sprintf('%s__%s__%s', $structure->getDsId(), $structure->getSort(), $value->getDsId());
                $content[$key] = $value->getValue();
            }
        }

        $values = [
            'eid' => $eid,
            'elementtypeId' => $elementtypeId,
            'elementtypeVersion' => $elementtypeVersion,
            'meta' => $meta,
            'content' => $content,
        ];

        return $values;
    }
136644
public function setVersionMixin(AbstractMappingEvent $event)
    {
        if (!$this->support($event->getDocument())) {
            return;
        }

        $event->getNode()->addMixin('mix:versionable');
    }
257379
protected function buildMapping($mappedClass)
    {
        return (\is_string($mappedClass) && \class_exists($mappedClass, true)) ?
            MappingFactory::fromClass($mappedClass) :
            MappingFactory::fromArray($mappedClass);
    }
1278143
protected static function setRelationships(array &$mappedClass, Mapping $mapping, string $className)
    {
        if (!empty($mappedClass[static::RELATIONSHIPS_KEY])) {
            foreach ($mappedClass[static::RELATIONSHIPS_KEY] as $propertyName => $urls) {
                if (false === \in_array($propertyName, static::getClassProperties($className))) {
                    throw new MappingException(
                        \sprintf(
                            'Could not find property %s in class %s because it does not exist.',
                            $propertyName,
                            $className
                        )
                    );
                }

                $mapping->setRelationshipUrls($propertyName, $urls);
            }
        }
    }
133989
public function addField($field)
    {
        $entityFieldNames = array_flip($this->mappedFields);
        if (array_key_exists($field, $entityFieldNames)) {
            parent::addField($entityFieldNames[$field]);
        }

        return $this;
    }
184129
public function softDeleteField (MapField $field, ElementInterface $owner)
	{
		/** @var MapElement $map */
		$map = $owner->getFieldValue($field->handle);

		\Craft::$app->getElements()->deleteElement($map);
	}