Stores value for $field in an external data source.

@param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo
@param \eZ\Publish\SPI\Persistence\Content\Field $field
@param array $context

@return mixed null|true
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);
        }
    }
840920
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context)
    {
        $this->gateway->deleteFieldData($versionInfo, $fieldIds);

        return true;
    }
619427
public function storeFieldData(VersionInfo $versionInfo, Field $field)
    {
        if ($field->value->data === null) {
            return;
        }

        $doc = new DOMDocument();
        if (!$doc->loadXML($field->value->data)) {
            return;
        }

        // Get all element tag types that contain url's or object_remote_id
        $urls = [];
        $remoteIds = [];
        $elements = [];
        foreach (['link', 'embed', 'embed-inline'] as $tagName) {
            $tags = $doc->getElementsByTagName($tagName);
            if ($tags->length === 0) {
                continue;
            }

            // First loop on $elements to populate $urls & $remoteIds
            /** @var $tag \DOMElement */
            foreach ($tags as $tag) {
                $url = null;
                if ($tag->hasAttribute('url')) {
                    $url = $tag->getAttribute('url');
                } elseif ($tag->hasAttribute('href')) {
                    $url = $tag->getAttribute('href');
                } elseif ($tag->hasAttribute('object_remote_id')) {
                    $remoteIds[$tag->getAttribute('object_remote_id')] = true;
                } else {
                    continue;
                }

                // Keep url unique if it has value
                if ($url) {
                    $urls[$url] = true;
                }

                $elements[] = $tag;
            }
        }
        unset($tags);

        // If we found some elements, fix them to point to internal ids
        if (!empty($elements)) {
            $linksIds = $this->getUrlIdMap(array_keys($urls));
            $objectRemoteIdMap = $this->getObjectId(array_keys($remoteIds));
            $urlLinkSet = [];

            // Now loop again to insert the right value in "url_id" attribute and fix "object_remote_id"
            /** @var $element \DOMElement */
            foreach ($elements as $element) {
                if ($element->hasAttribute('url')) {
                    $url = $element->getAttribute('url');
                    if (!$url) {
                        throw new NotFoundException('<link url=', $url);
                    }

                    // Insert url once if not already existing
                    if (!isset($linksIds[$url])) {
                        $linksIds[$url] = $this->insertUrl($url);
                    }
                    if (!isset($urlLinkSet[$url])) {
                        $this->linkUrl($linksIds[$url], $field->id, $versionInfo->versionNo);
                        $urlLinkSet[$url] = true;
                    }

                    $element->setAttribute('url_id', $linksIds[$url]);
                    $element->removeAttribute('url');
                } elseif ($element->hasAttribute('href')) {
                    $url = $element->getAttribute('href');
                    if (!$url) {
                        throw new NotFoundException('<link href=', $url);
                    }

                    // Insert url once if not already existing
                    if (!isset($linksIds[$url])) {
                        $linksIds[$url] = $this->insertUrl($url);
                    }
                    if (!isset($urlLinkSet[$url])) {
                        $this->linkUrl($linksIds[$url], $field->id, $versionInfo->versionNo);
                        $urlLinkSet[$url] = true;
                    }

                    $element->setAttribute('url_id', $linksIds[$url]);
                    $element->removeAttribute('href');
                } elseif ($element->hasAttribute('object_remote_id')) {
                    $objectRemoteId = $element->getAttribute('object_remote_id');
                    if (!isset($objectRemoteIdMap[$objectRemoteId])) {
                        throw new NotFoundException('object_remote_id', $objectRemoteId);
                    }

                    $element->setAttribute('object_id', $objectRemoteIdMap[$objectRemoteId]);
                    $element->removeAttribute('object_remote_id');
                }
            }

            // Store xml changes back to field
            $field->value->data = $doc->saveXML();
        }

        // Return true if some elements where changed
        return !empty($elements);
    }
232795
protected function updateFieldData(VersionInfo $versionInfo, Field $field)
    {
        $connection = $this->getConnection();

        $updateQuery = $connection->createUpdateQuery();
        $updateQuery->update($connection->quoteTable('ezgmaplocation'))
            ->set(
                $connection->quoteColumn('latitude'),
                $updateQuery->bindValue($field->value->externalData['latitude'])
            )->set(
                $connection->quoteColumn('longitude'),
                $updateQuery->bindValue($field->value->externalData['longitude'])
            )->set(
                $connection->quoteColumn('address'),
                $updateQuery->bindValue($field->value->externalData['address'])
            )->where(
                $updateQuery->expr->lAnd(
                    $updateQuery->expr->eq(
                        $connection->quoteColumn('contentobject_attribute_id'),
                        $updateQuery->bindValue($field->id, null, \PDO::PARAM_INT)
                    ),
                    $updateQuery->expr->eq(
                        $connection->quoteColumn('contentobject_version'),
                        $updateQuery->bindValue($versionInfo->versionNo, null, \PDO::PARAM_INT)
                    )
                )
            );

        $updateQuery->prepare()->execute();
    }
184613
protected function loadFieldData($fieldId, $versionNo)
    {
        $selectQuery = $this->connection->createQueryBuilder();
        $selectQuery
            ->select(
                $this->connection->quoteIdentifier('latitude'),
                $this->connection->quoteIdentifier('longitude'),
                $this->connection->quoteIdentifier('address')
            )
            ->from($this->connection->quoteIdentifier('ezgmaplocation'))
            ->where(
                $selectQuery->expr()->andX(
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_attribute_id'),
                        ':fieldId'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_version'),
                        ':versionNo'
                    )
                )
            )
            ->setParameter(':fieldId', $fieldId, PDO::PARAM_INT)
            ->setParameter(':versionNo', $versionNo, PDO::PARAM_INT)
        ;

        $statement = $selectQuery->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
        if (!isset($rows[0])) {
            return null;
        }

        // Cast coordinates as the DB can return them as strings
        $rows[0]['latitude'] = (float)$rows[0]['latitude'];
        $rows[0]['longitude'] = (float)$rows[0]['longitude'];

        return $rows[0];
    }
908067
public function getUserField($field = null, $userInfo = null) {
		if (empty($field)) {
			return null;
		}

		if (!empty($userInfo) && is_array($userInfo)) {
			$targetUserInfo = $userInfo;
		} else {
			$targetUserInfo = $this->_userInfo;
		}

		if (empty($targetUserInfo) || !is_array($targetUserInfo)) {
			return null;
		}

		$result = Hash::get($targetUserInfo, $field);

		return $result;
	}
1211293
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->delete($this->connection->quoteIdentifier('eztags_attribute_link'))
            ->where(
                $query->expr()->andX(
                    $query->expr()->in('objectattribute_id', [':objectattribute_id']),
                    $query->expr()->eq('objectattribute_version', ':objectattribute_version')
                )
            )
            ->setParameter(':objectattribute_id', $fieldIds, Connection::PARAM_INT_ARRAY)
            ->setParameter(':objectattribute_version', $versionInfo->versionNo, PDO::PARAM_INT);

        $query->execute();
    }
1335807
private function getFieldValue($field)
    {
        return isset($this->values[$field]) ? $this->values[$field] : null;
    }
281470
public function updateField(Field $field, StorageFieldValue $value)
    {
        try {
            return $this->innerGateway->updateField($field, $value);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
236785
protected function _canBeEmpty($field, $context)
    {
        $allowed = $field->isEmptyAllowed();

        if (!is_string($allowed) && is_callable($allowed)) {
            return $allowed($context);
        }

        $newRecord = $context['newRecord'];
        if (in_array($allowed, ['create', 'update'], true)) {
            $allowed = (
                ($allowed === 'create' && $newRecord) ||
                ($allowed === 'update' && !$newRecord)
            );
        }

        return $allowed;
    }
1096313
public function deleteFieldData($fieldType, VersionInfo $versionInfo, array $ids)
    {
        $this->storageRegistry->getStorage($fieldType)
            ->deleteFieldData($versionInfo, $ids, $this->context);
    }
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();
    }
472686
final public function getRowFieldValue($field)
    {

        //If value exists;
        if (array_key_exists($field, $this->schema)) {
            return $this->schema[$field]->Value;
        }
        return null;
    }
1158122
protected function _deriveFieldFromContext($field)
    {
        $controller = $this->_controller();
        $entity = $this->_entity();
        $request = $this->_request();
        $value = $entity->get($field);

        if ($value) {
            return $value;
        }

        $path = "{$controller->modelClass}.{$field}";
        if (!empty($request->getData())) {
            $value = Hash::get((array)$request->getData(), $path);
        }

        $singularVar = Inflector::variable($controller->modelClass);
        if (!empty($controller->viewVars[$singularVar])) {
            $value = $entity->get($field);
        }

        return $value;
    }
176598
public function deleteFields($contentId, VersionInfo $versionInfo)
    {
        foreach ($this->contentGateway->getFieldIdsByType($contentId, $versionInfo->versionNo) as $fieldType => $ids) {
            $this->storageHandler->deleteFieldData($fieldType, $versionInfo, $ids);
        }
        $this->contentGateway->deleteFields($contentId, $versionInfo->versionNo);
    }
584992
protected function loadFieldData($fieldId, $versionNo)
    {
        $connection = $this->getConnection();

        $selectQuery = $connection->createSelectQuery();
        $selectQuery->select(
            $connection->quoteColumn('latitude'),
            $connection->quoteColumn('longitude'),
            $connection->quoteColumn('address')
        )->from(
            $connection->quoteTable('ezgmaplocation')
        )->where(
            $selectQuery->expr->lAnd(
                $selectQuery->expr->eq(
                    $connection->quoteColumn('contentobject_attribute_id'),
                    $selectQuery->bindValue($fieldId, null, \PDO::PARAM_INT)
                ),
                $selectQuery->expr->eq(
                    $connection->quoteColumn('contentobject_version'),
                    $selectQuery->bindValue($versionNo, null, \PDO::PARAM_INT)
                )
            )
        );

        $statement = $selectQuery->prepare();
        $statement->execute();

        $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);

        if (!isset($rows[0])) {
            return null;
        }

        // Cast coordinates as the DB can return them as strings
        $rows[0]['latitude'] = (float)$rows[0]['latitude'];
        $rows[0]['longitude'] = (float)$rows[0]['longitude'];

        return $rows[0];
    }
937090
private function assertValidField($field)
    {
        if ( ! isset($this->entityChangeSet[$field])) {
            throw new \InvalidArgumentException(sprintf(
                'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
                $field,
                get_class($this->getEntity())
            ));
        }
    }