Transforms a Content's ID integer into a domain specific Content object.

@param string|null $value

@return \eZ\Publish\API\Repository\Values\Content\Content|null

@throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
182121
public function reverseTransform($value): ?Content
    {
        if (empty($value)) {
            return null;
        }

        if (!filter_var($value, FILTER_VALIDATE_INT)) {
            throw new TransformationFailedException('Expected a numeric string.');
        }

        try {
            return $this->contentService->loadContent($value);
        } catch (NotFoundException $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }
    }
1072341
public function reverseTransform($value)
    {
        if ('' === $value || null === $value) {
            return null;
        }

        if (!is_scalar($value)) {
            throw new TransformationFailedException('Value is not scalar');
        }

        try {
            $hash = $this->getCacheHash($value);
            if (array_key_exists($hash, $this->cachedResults)) {
                $entity = $this->cachedResults[$hash];
            } else {
                //Result not in cache

                $alias = current($this->queryBuilder->getRootAliases());
                $query = $this->queryBuilder->andWhere(
                    sprintf('%s.%s = :key_transformer', $alias, $this->identifier)
                )
                    ->setParameter('key_transformer', $value)
                    ->getQuery();

                $entity = $query->getSingleResult();
                $this->cachedResults[$hash] = $entity; //Saves result in cache
            }
        } catch (\Exception $e) {
            if ($this->throwExceptionIfValueNotFoundInReverse) {
                throw new TransformationFailedException(
                    sprintf('The entity with key "%s" could not be found or is not unique', $value)
                );
            } else {
                return null;
            }
        }

        return $entity;
    }
737911
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof User) {
            throw new TransformationFailedException('Expected a ' . User::class . ' object.');
        }

        return $value->id;
    }
30698
public function reverseTransform($value)
    {
        if ($value === null || empty($value)) {
            return $this->fieldType->getEmptyValue();
        }

        return $this->fieldType->fromHash(['xml' => $value]);
    }
884309
public function body($value = null)
    {
        if (!func_num_args()) {
            return $this->_body;
        }
        $this->_body = (string) $value;
        return $this;
    }
304280
public function transform($value): ?string
    {
        if (null === $value) {
            return null;
        }

        if (!is_array($value) || array_diff(['id', 'module', 'function'], array_keys($value))) {
            throw new TransformationFailedException('Expected a valid array of data.');
        }

        return implode(':', [$value['id'], $value['module'], $value['function']]);
    }
524647
public static function convertEntities($value)
    {
        $converted = null;
        
        //deal with double encoded payload 
        $value = preg_replace('/&amp;/', '&', $value);     
        
        if (preg_match('/&#x?[\w]+/ms', $value)) {
            $converted = preg_replace('/(&#x?[\w]{2}\d?);?/ms', '$1;', $value);
            $converted = html_entity_decode($converted, ENT_QUOTES, 'UTF-8');
            $value    .= "\n" . str_replace(';;', ';', $converted);
        }
        // normalize obfuscated protocol handlers
        $value = preg_replace(
            '/(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t\s*:)|(d\s*a\s*t\s*a\s*:)/ms', 
            'javascript:', $value
        );
        
        return $value;
    }
1065290
public function transform($value)
    {
        if (null === $value) {
            return array();
        }
        if($this->identifier){
            return $this->identifier->getValue($value);
        }

        return $value->getId();
    }
1328429
public function prepareValue($value)
    {
        return $value === null ? null : Carbon::createFromFormat($this->format, $value)->toDateString();
    }
268560
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!\is_string($value) || !is_numeric($value)) {
            throw new TransformationFailedException('Expected a numeric string.');
        }

        return (float) $value;
    }
1047759
final public static function fromString(string $value)
    {
        $uuid = (new ShortUuid())->decode($value);
        if ($uuid->getVariant() !== Uuid::RFC_4122 || !\in_array($uuid->getVersion(), \range(1, 5), true)) {
            throw new InvalidIdentityException(
                \sprintf('Provided identity value "%s" is not a valid short UUID', $value)
            );
        }

        return new static($value);
    }
1126176
public function transform($value)
    {
        if ($value === null || $value == '') {
            return null;
        }
        if (!($value instanceof File)) {
            throw new TransformationFailedException('Expected an instance of a concrete5 file object.');
        }
        return intval($value->getFileID());
    }
308585
public function transform($value)
    {
        if (null !== $value && 1 !== $this->divisor) {
            if (!is_numeric($value)) {
                throw new TransformationFailedException('Expected a numeric.');
            }
            $value /= $this->divisor;
        }

        return parent::transform($value);
    }
654645
public function reverseTransform($value)
    {
        if ("" === $value || null === $value) {
            return null;
        }

        try {
            $route = $this->router->match($value);

            if (false === isset($route['_nodeTranslation']) || false === $route['_nodeTranslation'] instanceof NodeTranslation) {
                throw new TransformationFailedException('Matched route has no nodeTranslation');
            }

            return $route['_nodeTranslation'];

        } catch (RouteNotFoundException $e) {
            throw new TransformationFailedException('Cannot match URL to a nodeTranslation', 0, $e);
        }
    }
600969
public function setReasonCode($value)
    {
        $allowedReasonCodes = self::allowedReasonCodes();

        if (!in_array($value, $allowedReasonCodes, true)) {
            throw new DomainException(sprintf(self::MSG_UNEXPECTED_REASON_CODE, implode(', ', $allowedReasonCodes)));
        }

        return $this->setAttribute('reasonCode', $value);
    }
656390
public function setValue(string $value = null) : Element
    {
        if (!is_null($value)) {
            $tmp = preg_replace('/[^\d]/', '', $value);
            if (strlen($tmp)) {
                $value = $tmp;
                if ($value{0} != '0') {
                    $value = "0$value";
                }
            }
        }
        return parent::setValue($value);
    }
412209
public function assign($var, $value = null)
    {
        if (is_string($var)) {
            $this->_vars[$var] = $value;

            return $this;
        }

        if (is_array($var)) {
            foreach ($var as $key => $value) {
                if ($value instanceof AbstractClassContent) {
                    // trying to load subcontent
                    $subcontent = $this->getApplication()
                            ->getEntityManager()
                            ->getRepository(ClassUtils::getRealClass($value))
                            ->load($value, $this->getApplication()->getBBUserToken());
                    if (null !== $subcontent) {
                        $value = $subcontent;
                    }
                }

                $this->_vars[$key] = $value;
            }
        }

        return $this;
    }