Translate shorthand:
We may want to pass shorthand representations of models
for importing, seeding, mass actions, etc..

@param $value
354192
protected function translateShorthand(&$value)
    {
        // $value is an array but not an array of Entity(s)
        if(is_array($value) && !current($value) instanceof Entity){

            $this->array_walk($value, [$this, '_translate']);
        }
    }
1011301
public function push($value)
    {
        $this->checkType($value);
        $data = &$this->getDataPlaceHolder();
        array_push($data, $value);
    }
947296
public function filter($value)
    {
        return true === array_key_exists((string)$value, $this->translations) ? $this->translations[$value] : null;
    }
1044161
public function reverseTransform($value)
    {
        if (null === $value) {
            return;
        }

        if (!\is_array($value)) {
            throw new TransformationFailedException('Expected an array.');
        }

        if ('' === implode('', $value)) {
            return;
        }

        $emptyFields = [];

        foreach ($this->fields as $field) {
            if (!isset($value[$field])) {
                $emptyFields[] = $field;
            }
        }

        if (\count($emptyFields) > 0) {
            throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields)));
        }

        if (isset($value['month']) && !ctype_digit((string) $value['month'])) {
            throw new TransformationFailedException('This month is invalid');
        }

        if (isset($value['day']) && !ctype_digit((string) $value['day'])) {
            throw new TransformationFailedException('This day is invalid');
        }

        if (isset($value['year']) && !ctype_digit((string) $value['year'])) {
            throw new TransformationFailedException('This year is invalid');
        }

        if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) {
            throw new TransformationFailedException('This is an invalid date');
        }

        if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) {
            throw new TransformationFailedException('This hour is invalid');
        }

        if (isset($value['minute']) && !ctype_digit((string) $value['minute'])) {
            throw new TransformationFailedException('This minute is invalid');
        }

        if (isset($value['second']) && !ctype_digit((string) $value['second'])) {
            throw new TransformationFailedException('This second is invalid');
        }

        try {
            $dateTime = new \DateTime(sprintf(
                '%s-%s-%s %s:%s:%s',
                empty($value['year']) ? '1970' : $value['year'],
                empty($value['month']) ? '1' : $value['month'],
                empty($value['day']) ? '1' : $value['day'],
                empty($value['hour']) ? '0' : $value['hour'],
                empty($value['minute']) ? '0' : $value['minute'],
                empty($value['second']) ? '0' : $value['second']
                ),
                new \DateTimeZone($this->outputTimezone)
            );

            if ($this->inputTimezone !== $this->outputTimezone) {
                $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone));
            }
        } catch (\Exception $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }

        return $dateTime;
    }
446
public static function export($value)
	{
		if (!is_scalar($value))
		{
			throw new InvalidArgumentException(__METHOD__ . '() cannot export non-scalar values');
		}
		if (is_int($value))
		{
			return (string) $value;
		}
		if (is_float($value))
		{
			// Avoid locale issues by using sprintf()
			return preg_replace('(\\.?0+$)', '', sprintf('%F', $value));
		}

		return self::exportString((string) $value);
	}
70384
public static function convertToPhp($value)
    {
        if (is_string($value)) {
            return Translatable::createFromOriginalString($value);
        }

        if (is_array($value)) {
            return Translatable::createFromTranslations($value);
        }

        return null;
    }
711241
public function addDraftIsTransformedToMessageIdList($value)
    {
        if ($this->DraftIsTransformedToMessageIdList === null) {
            $this->DraftIsTransformedToMessageIdList = new \Protobuf\ScalarCollection();
        }

        $this->DraftIsTransformedToMessageIdList->add($value);
    }
1015067
public function add($value)
    {
        if (!$value instanceof Contact) {
            throw new InvalidArgumentException(
                sprintf(
                    '%s only accepts instances of %s.',
                    __FUNCTION__, Contact::class
                )
            );
        }

        return parent::add($value);
    }
370535
public void setFillTranslate( Float[] value) {
    PropertyValue propertyValue = fillTranslate(value);
    constantPropertyUsageMap.put(PROPERTY_FILL_TRANSLATE, propertyValue);
    layer.setProperties(propertyValue);
  }
570350
public function setHumanValue($value)
    {
        $this->humanValue = $value;
        $old = $this->value;
        $this->value = static::humanToPlain($value);
        $this->onUpdate($old);
    }
556528
public function prepValueForDB($value)
    {
        if ($value instanceof MultiValueField) {
            $value = $value->getValue();
        }
        if (is_object($value) || is_array($value)) {
            $value = json_encode($value);
        }

        return parent::prepValueForDB($value);
    }
1310661
private function addToStack($value)
    {
        $keys = \array_keys($this->stack);
        $this->stack[\end($keys)][] = $value;
    }
1273927
protected function loadGlobals($value) {
        $enabled = false;                                           // default
        if (is_bool($value) || is_int($value)) {
            $enabled = (bool) $value;
        }
        elseif (is_string($value)) {
            $value   = trim(strtolower($value));
            $enabled = ($value=='1' || $value=='on' || $value=='true');
        }
        if ($enabled && !function_exists('booltostr')) {            // prevent multiple includes
            include(MINISTRUTS_ROOT.'/src/globals.php');
        }
    }
170429
protected function setValue($value)
    {
        if (!is_string($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be a string", static::prototype());
        }

        if(!mb_check_encoding($value, 'UTF-8')) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be a UTF-8 encoded", static::prototype());
        }

        $this->value = $value;
    }
1018916
protected function optimizeValueForJavaScript($value)
    {
        // For every transformable type, let's see if
        // it needs to be transformed for JS-use.
        foreach ($this->types as $transformer) {
            $js = $this->{"transform{$transformer}"}($value);
            if (! is_null($js)) {
                return $js;
            }
        }
    }
102721
public function append($value)
    {
        if (!$value instanceof $this->currencyClass) {
            throw new \InvalidArgumentException(sprintf('$newval must be an instance of Currency, instance of "%s" given', get_class($value)));
        }

        parent::append($value);
    }
1083777
public function processValue($value)
	{
		$clean = strip_tags($value);

		if (array_key_exists($clean, $this->types)) {
			if (!isset($this->types[$clean]['value'])) {
				$this->types[$clean]['value'] = 0;
			}
			$this->types[$clean]['value'] += 1;
		}
	}