Load given field if able to, define his value and return it.

@example
public function getRelatedEntity()
{
return $this->load('relatedEntity');
}

@param string $field

@return mixed|null field value if retrieved
356625
protected function load($field)
    {
        if (!is_null($this->$field)
            || !$this->delegatesCollection
            || !$this->delegatesCollection->containsKey($key = strtolower($field))
        ) {
            return $this->$field;
        }

        $loader = $this->delegatesCollection->get($key);
        $this->delegatesCollection->remove($key);

        return $this->$field = $loader($this);
    }
1155265
protected function getFieldValue($field)
    {
        if (is_string($field)) {
            if (!isset($this->allFields[$field])) {
                throw new ApplicationException(Lang::get(
                    'backend::lang.form.missing_definition',
                    compact('field')
                ));
            }

            $field = $this->allFields[$field];
        }

        $defaultValue = !$this->model->exists
            ? $field->getDefaultFromData($this->data)
            : null;

        return $field->getValueFromData(
            $this->data, 
            is_string($defaultValue) ? trans($defaultValue) : $defaultValue
        );
    }
466297
public function get($entity)
    {
        $key = $this->mapping['fieldname'];
        $valueMethod = 'get' . ucfirst($key);
        $value = $entity->$valueMethod();

        return $value;
    }
673703
public function getFieldType($object, $field)
	{
		$metadata  = $this->manager->getClassMetadata(get_class($object));

		if ($metadata->hasField($field)) {
			return $metadata->getTypeOfField($field);
		} else if ($metadata->hasAssociation($field) && $metadata->isSingleValuedAssociation($field)) {
			return self::ASSOCIATION_TO_ONE;
		} else if ($metadata->hasAssociation($field) && $metadata->isCollectionValuedAssociation($field)) {
			return self::ASSOCIATION_TO_MANY;
		}

		return null;
	}
242702
protected function getDBField($field)
    {
        $dbField = null;
        if (stristr($field, self::SEPARATOR) !== false) {
            list ($relationName, $relationField) = explode(self::SEPARATOR, $field);
            $class = $this->getDataObjectInstance()->getRelationClass($relationName);
            if (!$class) {
                throw new InvalidArgumentException(sprintf(
                    'Could not find relation %s on %s',
                    $relationName,
                    $this->getDataObjectClass()
                ));
            }
            return Injector::inst()->get($class)->dbObject($relationField);
        }

        return $this->getDataObjectInstance()->dbObject($field);
    }
1278870
public function getField($field)
    {
        // If we already have a value in $this->record, then we should just return that
        if (isset($this->record[$field])) {
            return $this->record[$field];
        }

        // Do we have a field that needs to be lazy loaded?
        if (isset($this->record[$field . '_Lazy'])) {
            $tableClass = $this->record[$field . '_Lazy'];
            $this->loadLazyFields($tableClass);
        }
        $schema = static::getSchema();

        // Support unary relations as fields
        if ($schema->unaryComponent(static::class, $field)) {
            return $this->getComponent($field);
        }

        // In case of complex fields, return the DBField object
        if ($schema->compositeField(static::class, $field)) {
            $this->record[$field] = $this->dbObject($field);
        }

        return isset($this->record[$field]) ? $this->record[$field] : null;
    }
620711
public function getNewValue(string $field)
    {
        $change = $this->objectChangeSet->getFieldChange($field);

        if ($change !== null) {
            return $change->getNewValue();
        }
    }
932396
protected function _getField() {
        //We can access to a field of the current Entity or a linked Entity (foreign key)
        //If the field name contain a "." it's the second case
        $fields = [];
        $fieldsData = $this->_entity->fields();

        //We have to analyze a classic field without linked Entity
        if (!preg_match('#\.#isU', $this->_field)) {
            if (isset($fieldsData[$this->_field])) {
                $fields = [$fieldsData[$this->_field]->value];
            }
            else {
                throw new MissingEntityException('The field "' . $this->_field . '" in the Entity "' . $this->_entity->name() . '" does\'nt exist');
            }
        }
        else {
            //Here it's sure that we have a linked Entity. But we don't compute "One to One and One to Many" in the same way than the 2 other
            //because in the two first the field value is an Entity object and in the two other, the field value is a Collection
            //To know which type of linked Entity it's, we just split the name on the "." and we take the index 0 of the generated array

            $entityName = explode('.', $this->_field);

            if (array_key_exists($entityName[0], $fieldsData) && $fieldsData[$entityName[0]]->foreign != null) {
                /** @var int $foreignType : the type of the foreign key */
                $foreignType = $fieldsData[$entityName[0]]->foreign->type();
                /** @var mixed $fieldValue : the value of the sub-field from the Entity (post.article.content->value) */
                $fieldValue = $fieldsData[$entityName[0]]->value->fields()[$entityName[1]];

                if ($foreignType == ForeignKey::ONE_TO_MANY || $foreignType == ForeignKey::MANY_TO_ONE) {
                    $fields = $this->_getForeignKeyFieldValue($fieldValue);
                }
                else { //We must get all the sub entities as an array an then loop through this array to get the field values
                    foreach ($fieldValue->data() as $fieldValueCollection) {
                        $fields = array_merge($fields, $this->_getForeignKeyFieldValue($fieldValueCollection));
                    }
                }
            }
            else {
                throw new MissingEntityException('The field "' . $this->_field . '" in the Entity "' . $this->_entity->name() . '" does\'nt exist');
            }
        }

        return $fields;
    }
899535
public function get($field)
    {
        if (!is_null($this->filtered) && ! is_null($this->filtered[0])) {
            return isset($this->filtered[0][0][$field]) ? $this->filtered[0][0][$field] : null;
        }

        // Todo: Get values of entities
    }
1332253
public function getField($field, $token = null)
    {
        $session = $this->app->tokens->get($token);
        return ($session && isset($session[$field]))? $session[$field] : null;
    }
1267416
public function getEntityAttributeValue($field)
    {
        if ($field) {
            $functionName = 'get'.ucfirst($field);

            // Avoid error when the widget refer to a property that has been removed
            if (!method_exists($this, $functionName)) {
                return;
            }

            $fieldValue = $this->{$functionName}();
        } else {
            $fieldValue = null;
        }

        return $fieldValue;
    }
562226
protected function getField($field)
    {
        if ($this->isFieldSupported($field) && isset($this->fields[ $field ])) {
            return $this->fields[ $field ];
        }

        return null;
    }
279744
public function dbObject($field)
    {
        $fields = $this->compositeDatabaseFields();
        if (!isset($fields[$field])) {
            return null;
        }

        // Build nested field
        $key = $this->getName() . $field;
        $spec = $fields[$field];
        /** @var DBField $fieldObject */
        $fieldObject = Injector::inst()->create($spec, $key);
        $fieldObject->setValue($this->getField($field), null, false);
        return $fieldObject;
    }
1186060
public function scalar($field) {
		$result = $this->first();
		if (empty($result)) {
			return null;
		}
		return $result->$field;
	}
1269466
private function getAssociationByField(string $field) : ?Association
    {
        list($name) = explode('.', $this->table->aliasField($field), 2);

        if ($name === $this->table->getAlias()) {
            return null;
        }

        if (! $this->table->hasAssociation($name)) {
            throw new \RuntimeException(sprintf('Table "%s" does not have association "%s"', $this->table->getAlias(), $name));
        }

        return $this->table->getAssociation($name);
    }
241436
public function getField($field)
    {
        return $this->getFields()->filter(function($input) use ($field) {
            return $field === $input->getName();
        })->first();
    }
879080
public function findValue($field) {
        $row = $this->select($field)->findOne();

        //false or null
        if (!$row) {
            return $row;
        }

        return $row[$field];
    }