Populates $field value property based on the external data.

@param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo
@param \eZ\Publish\SPI\Persistence\Content\Field $field
@param array $context
968287
public function getFieldData(VersionInfo $versionInfo, Field $field, array $context)
    {
        $product = null;

        $productId = $this->gateway->getFieldData($versionInfo);
        if (!empty($productId)) {
            $product = $this->productRepository->find($productId);
        }

        if ($product instanceof ProductInterface) {
            $product->setCurrentLocale(
                $this->localeConverter->convertToPOSIX($field->languageCode)
            );
        }

        $field->value->externalData = $product;
    }
158857
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
    {
        if (empty($fieldIds)) {
            // Nothing to do
            return;
        }

        $connection = $this->getConnection();

        $deleteQuery = $connection->createDeleteQuery();
        $deleteQuery->deleteFrom(
            $connection->quoteTable('ezgmaplocation')
        )->where(
            $deleteQuery->expr->lAnd(
                $deleteQuery->expr->in(
                    $connection->quoteColumn('contentobject_attribute_id'),
                    $fieldIds
                ),
                $deleteQuery->expr->eq(
                    $connection->quoteColumn('contentobject_version'),
                    $deleteQuery->bindValue($versionInfo->versionNo, null, \PDO::PARAM_INT)
                )
            )
        );

        $deleteQuery->prepare()->execute();
    }
407298
public function compareFields($value, $field, $context) {
		if (!isset($context['data'][$field])) {
			return true;
		}
		if ($value === $context['data'][$field]) {
			return true;
		}

		return false;
	}
778071
public function setField($key, $name, $version = '', array $options = [])
    {
        $field = [
            'name' => $name
        ];

        if (!empty($version)) {
            $field['version'] = $version;
        }

        if (!empty($options)) {
            $field['options'] = $options;
        }

        $this->fields[$key] = $field;

        return $this;
    }
575392
public function getNodePathString(VersionInfo $versionInfo)
    {
        $selectQuery = $this->connection->createQueryBuilder();
        $selectQuery
            ->select($this->connection->quoteIdentifier('path_identification_string'))
            ->from($this->connection->quoteIdentifier('ezcontentobject_tree'))
            ->where(
                $selectQuery->expr()->andX(
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_id'),
                        ':contentObjectId'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_version'),
                        ':versionNo'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('node_id'),
                        $this->connection->quoteIdentifier('main_node_id')
                    )
                )
            )
            ->setParameter(':contentObjectId', $versionInfo->contentInfo->id, PDO::PARAM_INT)
            ->setParameter(':versionNo', $versionInfo->versionNo, PDO::PARAM_INT)
        ;

        $statement = $selectQuery->execute();

        return $statement->fetchColumn();
    }
135914
private void marshalVersionField() {
    PropertyMetadata versionMetadata = entityMetadata.getVersionMetadata();
    if (versionMetadata != null) {
      long version = (long) IntrospectionUtils.getFieldValue(versionMetadata, entity);
      ValueBuilder<?, ?, ?> valueBuilder = versionMetadata.getMapper().toDatastore(version + 1);
      valueBuilder.setExcludeFromIndexes(!versionMetadata.isIndexed());
      entityBuilder.set(versionMetadata.getMappedName(), valueBuilder.build());
    }
  }
1295636
public function storeFileReference(VersionInfo $versionInfo, Field $field)
    {
        $referencedData = $this->getFileReferenceData($field->id, $versionInfo->versionNo);

        if ($referencedData === null) {
            $this->storeNewFieldData($versionInfo, $field);
        } elseif (is_array($referencedData) && !empty(array_diff_assoc($referencedData, $field->value->externalData))) {
            $this->updateFieldData($versionInfo, $field);
        }

        return false;
    }
198485
public function map($field, $context = null)
    {
        if ($context instanceof JsonDefinition &&
            $context->getField($field['fieldName']) instanceof DefinitionElementInterface
        ) {
            $fieldInformation = $context->getField($field['fieldName'])
                ->getDefAsArray();

            // in this context, the default type is the doctrine type..
            if (isset($fieldInformation['doctrineType'])) {
                $fieldInformation['type'] = $fieldInformation['doctrineType'];
            }

            $field = array_merge($field, $fieldInformation);
        }

        return $field;
    }
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)
            );
        }
    }
672570
protected function populateValue($field) : bool
    {
        $elements = $this->getFields($field);

        $return = true;

        foreach ($elements as $element) {
            if ($element instanceof AbstractField) {
                if (!$this->isSubmit()) {
                    $return = !$this->getDefaultValue($element) ? false : $return;
                } else {
                    $return = !$this->getFieldValue($element) ? false : $return;
                }
            } else {
                $return = !$this->populateValue($element) ? false : $return;
            }
        }

        return $return;
    }
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();
    }
83222
public function storeFieldData( VersionInfo $versionInfo, Field $field )
    {
        $connection = $this->getConnection();
        foreach ( $field->value->externalData as $meta )
        {
            $insertQuery = $connection->createInsertQuery();
            $insertQuery
                ->insertInto( $connection->quoteTable( self::TABLE ) )
                ->set(
                    $connection->quoteColumn( "meta_name" ),
                    $insertQuery->bindValue( $meta["meta_name"], null, PDO::PARAM_STR )
                )->set(
                    $connection->quoteColumn( "meta_content" ),
                    $insertQuery->bindValue( $meta["meta_content"], null, PDO::PARAM_STR )
                )->set(
                    $connection->quoteColumn( "objectattribute_id" ),
                    $insertQuery->bindValue( $field->id, null, PDO::PARAM_INT )
                )->set(
                    $connection->quoteColumn( "objectattribute_version" ),
                    $insertQuery->bindValue( $versionInfo->versionNo, null, PDO::PARAM_INT )
                );
            $insertQuery->prepare()->execute();
        }
    }
337442
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds)
    {
        $query = $this->dbHandler->createDeleteQuery();
        $query
            ->deleteFrom($this->dbHandler->quoteTable('eztags_attribute_link'))
            ->where(
                $query->expr->lAnd(
                    $query->expr->in(
                        $this->dbHandler->quoteColumn('objectattribute_id'),
                        $fieldIds
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('objectattribute_version'),
                        $query->bindValue($versionInfo->versionNo, null, PDO::PARAM_INT)
                    )
                )
            );

        $query->prepare()->execute();
    }
341802
private void processField(Field field) {
    PropertyMetadata propertyMetadata = IntrospectionUtils.getPropertyMetadata(field);
    if (propertyMetadata != null) {
      // If the field is from a super class, there might be some
      // overrides, so process those.
      if (!field.getDeclaringClass().equals(entityClass)) {
        applyPropertyOverride(propertyMetadata);
      }
      entityMetadata.putPropertyMetadata(propertyMetadata);
      if (field.isAnnotationPresent(Version.class)) {
        processVersionField(propertyMetadata);
      } else if (field.isAnnotationPresent(CreatedTimestamp.class)) {
        processCreatedTimestampField(propertyMetadata);
      } else if (field.isAnnotationPresent(UpdatedTimestamp.class)) {
        processUpdatedTimestampField(propertyMetadata);
      }
    }
  }
768925
public function addMappedField(ElementVersionMappedField $mappedField)
    {
        if (!$this->mappedFields->containsKey($mappedField->getLanguage())) {
            $this->mappedFields->set($mappedField->getLanguage(), $mappedField);
            $mappedField->setElementVersion($this);
        }

        return $this;
    }
350143
public function setFieldValue(object $document, string $field, $value) : void
    {
        if ($document instanceof GhostObjectInterface && ! $document->isProxyInitialized()) {
            //property changes to an uninitialized proxy will not be tracked or persisted,
            //so the proxy needs to be loaded first.
            $document->initializeProxy();
        }

        $this->reflFields[$field]->setValue($document, $value);
    }
1248184
public function map($field, $context = null)
    {
        $title = 'Please add title';

        if (array_key_exists('title', $field) && !empty($field['title'])) {
            $title = $field['title'];
        } elseif (array_key_exists('fieldName', $field) && !empty($field['fieldName'])) {
            $value = $field['fieldName'];
            // Field have dots
            if (strpos($value, '.') !== false) {
                $value = str_replace('.', ' ', str_replace('.0', '.array', $value));
            }
            $value = preg_replace('/(?<=\\w)(?=[A-Z])/', " $1", $value);
            $title = ucfirst(strtolower($value));
        }
        $field['title'] = trim($title);
        return $field;
    }