Process a single field into an output

@param string $field The field to process.
@param \Cake\Datasource\EntityInterface $data The entity data.
@param array $options Processing options.
@return string|null|array|bool|int
500391
public function process($field, EntityInterface $data, array $options = [])
    {
        $this->setContext($data);

        $value = $this->fieldValue($data, $field);
        $options += ['formatter' => null];

        if ($options['formatter'] === 'element') {
            $context = $this->getContext();

            return $this->_View->element($options['element'], compact('context', 'field', 'value', 'options'));
        }

        if ($options['formatter'] === 'relation') {
            $relation = $this->relation($field);
            if ($relation) {
                return $relation['output'];
            }
        }

        if (is_callable($options['formatter'])) {
            return $options['formatter']($field, $value, $this->getContext(), $options, $this->getView());
        }

        $value = $this->introspect($field, $value, $options);

        return $value;
    }
1323817
public function getFieldValue(Content $content, $field, $language, $options = [])
    {
        $fieldObj = $content->getField($field, $language);

        if (null === $fieldObj) {
            $fieldObj = $content->getField($field);
        }

        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
        $imageFieldIdentifier = $this->getImageFieldIdentifier($content->id, $language);

        $relatedContentId = $this->getRelation($content, $fieldObj->fieldDefIdentifier, $language);
        $mapping = $this->relationMapper->getMapping($contentType->identifier, $field);

        try {
            if ($relatedContentId && $mapping) {
                $relatedContent = $this->contentService->loadContent($relatedContentId);

                if ($relatedContent && $relatedContent->versionInfo->contentInfo->published) {
                    $relatedContentType = $this->contentTypeService->loadContentType($relatedContent->contentInfo->contentTypeId);

                    if ($relatedContentType->identifier != $mapping['content']) {
                        throw new InvalidRelationException(
                            sprintf(
                                "Invalid relation: field '%s:%s' (object: %s, field: %s) has improper relation to object '%s' (object: %s) but '%s:%s' expected.",
                                $contentType->identifier,
                                $field,
                                $content->id,
                                $fieldObj->id,
                                $relatedContentType->identifier,
                                $relatedContentId,
                                $mapping['content'],
                                $mapping['field']
                            )
                        );
                    }
                    $relatedField = $content->getField($mapping['field'], $language);
                    $value = $relatedField ? $this->getParsedFieldValue($relatedField, $relatedContent, $language, $imageFieldIdentifier, $options) : '';
                } else {
                    $value = '';
                }
            } else {
                $value = $fieldObj ? $this->getParsedFieldValue($fieldObj, $content, $language, $imageFieldIdentifier, $options) : '';
            }
        } catch (InvalidRelationException $exception) {
            $this->logger->warning($exception->getMessage());

            $value = '';
        }

        return $value;
    }
97569
public function afterSave(Event $event, EntityInterface $entity, ArrayObject $options = null)
    {
        if ($entity->isNew()) {
            snapshot();
        }
    }
800594
public function sortFieldsForProcessing($fields, $options = []) {
		if (!empty($this->collection_object)) {
			$collection = array_key_get($this->collection_object->data, $options['details_collection_key'] ?? null);
			foreach ($fields as $k => $v) {
				// skip certain values
				if ($k == $this::SEPARATOR_HORIZONTAL || $k == $this::SEPARATOR_VERTICAL || !empty($v['options']['process_submit']) || !empty($v['options']['custom_renderer'])) {
					unset($fields[$k]);
					continue;
				}
				// sort
				if (isset($fields[$k]['options']['order_for_defaults'])) {
					$fields[$k]['order_for_defaults'] = $fields[$k]['options']['order_for_defaults'];
				} else if (in_array($k, $collection['pk'] ?? [])) {
					$fields[$k]['order_for_defaults'] = -32000;
				} else if (!empty($v['options']['default']) && strpos($v['options']['default'], 'dependent::') !== false) { // processed last
					$fields[$k]['order_for_defaults'] = 2147483647 - 32000 + intval(str_replace(['dependent::', 'static::'], '', $v['options']['default']));
				} else if (!empty($v['options']['default']) && (strpos($v['options']['default'], 'parent::') !== false || strpos($v['options']['default'], 'static::') !== false)) {
					$column = str_replace(['parent::', 'static::'], '', $v['options']['default']);
					$fields[$k]['order_for_defaults'] = ($fields[$column]['order_for_defaults'] ?? 0) + 100;
				} else if (!isset($fields[$k]['order_for_defaults'])) {
					$fields[$k]['order_for_defaults'] = (($this->data[$fields[$k]['options']['container_link']]['order'] ?? 1000) * 10000) + ($fields[$k]['row_order'] * 100) + $fields[$k]['order'];
				}
			}
			array_key_sort($fields, ['order_for_defaults' => SORT_ASC], ['order_for_defaults' => SORT_NUMERIC]);
		}
		return $fields;
	}
143098
public function renderField(GridViewInterface $gridView, Field $field, $data)
    {
        $options = $this->parser->parseOptions(
            $this->shadowOptions[$field->getName()] ?? $this->shadowOptions[$field->getName()] = $field->getOptions(),
            $gridView->getRequestConfiguration()->getRequest(),
            $data
        );

        $field->setOptions($options);

        return $this->renderer->renderField($gridView, $field, $data);
    }
146397
protected function _setUploadColumns($entity, $field, $options = [])
    {
        $fieldConfig = $this->config($field);
        $_upload = $this->_uploads[$field];

        // set all columns with values
        foreach ($fieldConfig['fields'] as $key => $column) {
            if ($column) {
                if ($key == "url") {
                    $entity->set($column, $this->_getUrl($entity, $field));
                }
                if ($key == "directory") {
                    $entity->set($column, $this->_getPath($entity, $field, ['root' => false, 'file' => false]));
                }
                if ($key == "type") {
                    $entity->set($column, $_upload['type']);
                }
                if ($key == "size") {
                    $entity->set($column, $_upload['size']);
                }
                if ($key == "fileName") {
                    $entity->set($column, $this->_getFileName($entity, $field, $options = []));
                }
                if ($key == "filePath") {
                    $entity->set($column, $this->_getPath($entity, $field, ['root' => false, 'file' => true]));
                }
            }
        }
        return $entity;
    }
572484
protected function processQueryField($data, $field)
    {
        $default        = $this->setFieldDefaultValue($field);
        $field['value'] = $this->setFieldValue($field['name'], $data, $default);
        $field['type']  = $this->setFieldDataType($field);

        return $this->processField('sanitize', $field);
    }
926248
public function provide($data = null, array $options = [])
    {
        $result = '';

        // Return as is, if not empty
        if (!empty($data)) {
            return $data;
        }

        // Fallback on the field name
        $result = $this->config->getField();

        $result = $this->cleanName($result);

        return $result;
    }
73420
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options) {
		$fields = $this->_getMappedFields();

		foreach ($fields as $map => $field) {
			if (!$entity->get($map)) {
				continue;
			}
			$val = $entity->get($map);
			$entity->set($field, $this->_encode($val));
		}
	}
238335
public function deserialize($data, $object, array $options = [])
    {
        $properties = $this->getSerializableProperties($object, [self::INCLUDE_MANY_TO_ONE]);
        //update the mapObjectToEntity method instead of doing this
        $data = json_decode(json_encode($data));

        return $this->mapObjectToEntity(
            $properties,
            $this->resolveData($properties, $data, get_class($object)),
            $object
        );
    }
1059029
public function processNode(Parser $parser, $variable, $data, array $options)
    {
        $this->processAction($parser, $variable, $data, $options);

        return null;
    }
462309
public function getResult($wheres = [], $selectField = '*', $options = NULL)
    {
        try {
            if (is_array($wheres) && count($wheres) > 0) {
                foreach ($wheres as $field => $value) {
                    if (is_array($value)) {
                        $this->db->where($field, $value, self::OPERATOR_IS_IN);
                    } else {
                        $this->db->where($field, $value, self::OPERATOR_EQUAL_TO);
                    }
                }
            } else {
                $this->db->where($this->primaryKey, $wheres, self::OPERATOR_EQUAL_TO);
            }
            if (isset($options['orderBy']) && is_array($options['orderBy'])) {
                foreach ($options['orderBy'] as $column => $direction) {
                    $this->db->orderBy($column, $direction);
                }
            }
            $result = $this->db->get($this->table, NULL, $selectField);
            $this->debug->debug(__FUNCTION__, 'Format is get all Result => ' . json_encode($result));

            return $result;
        }
        catch (\Exception $e) {
            $this->debug->error(__FUNCTION__, $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage());

            return NULL;
        }
    }
866545
protected function _buildValue($field, $options, $params)
    {
        $string = null;

        if ($options['operator'] === 'LIKE') {
            $string .= '%';
        }
        $string .= Hash::get($params, $options['column']);
        if ($options['operator'] === 'LIKE') {
            $string .= '%';
        }
        return $string;
    }
287574
public function filename(EntityInterface $entity, array $options = []) {
		$config = array_merge($this->getConfig(), $options);
		if ($config['preserveFilename'] === true) {
			return $this->_preserveFilename($entity, $config);
		}

		return $this->_buildFilename($entity, $config);
	}
125544
public function validates($entity, $options = [])
    {
        $fieldname = $this->name();

        if (!isset($entity->{$fieldname})) {
            return true;
        }
        return $entity->{$fieldname}->validates($options);
    }
313362
public function deserialize($string, array $options = [])
    {
        $plain = @unserialize($string);

        if ((!is_object($plain) && !is_array($plain)) || $plain === false) {
            return $string;
        }

        if ($plain instanceof EntityPointer) {
            return $this->entityManager->get($plain);
        }

        return $plain;

    }
124130
public function val($field, $options = [])
    {
        $val = parent::val($field, $options);
        if ($val === null) {
            $parts  = explode('.', $field);
            $entity = $this->entity($parts);

            if ($entity instanceof Data) {
                $key = array_pop($parts);
                $val = $entity->get($key);
            }
        }

        return $val;
    }