Transforms a string (id) to an object (Page).

@param string $id

@throws TransformationFailedException if object (Page) is not found.

@return Page|null
355676
public function reverseTransform($id)
    {
        if (!$id) {
            return;
        }

        $page = $this->om
            ->getRepository('VictoirePageBundle:Page')
            ->findOneBy(['id' => $id]);

        if (null === $page) {
            throw new TransformationFailedException(sprintf(
                'La page #"%s" est introuvable !',
                $id
            ));
        }

        return $page;
    }
575953
protected function escapeId($id)
    {
        if (!$this->replace) {
            return $id;
        }

        return str_replace(array_keys($this->replace), array_values($this->replace), $id);
    }
70957
public function reverseTransform($id)
    {
        if (!$id) {
            return null;
        }

        $model = $this->loader->load($id);

        if (null === $model) {
            return null;
            // throw new TransformationFailedException(sprintf(
            // 'An user with id "%s" does not exist!',
            // $id
            // ));
        }

        return $model;
    }
1280205
public function getById($id)
    {
        $record = NavigationRecord::findOne(['id' => $id]);

        if ($record) {
            return new NavigationModel($record->getAttributes());
        }

        return null;
    }
673428
public function raw(string $id)
    {
        $id = $this->getRealId($id);

        if (array_key_exists($id, $this->definitions)) {
            return $this->definitions[$id];
        }

        throw new Exception\NotFoundException($id);
    }
1097514
public function reverseTransform($content)
    {
        if (null === $content) {
            return null;
        }

        if (!is_string($content)) {
            throw new TransformationFailedException(sprintf(
                'Expected string, %s given',
                gettype($content)
            ));
        }

        //replace span with comment tag, so no weird style is added on front-end
        $content = StripTagsUtil::replaceSpanWith($content, StripTagsUtil::COMMENT_REPLACEMENT);

        return $content;
    }
803007
public function toModelAttribute($id)
	{
		if ($id === null) {
			$id = self::VALUE_NULL;
		}

		if (! array_key_exists($id,	$this->_map) ) {
			throw new Exception('Conversion from SimpleWorkflow failed : no key found for id = '.$id);
		}
		$value = $this->_map[$id];
		return ($value === self::VALUE_NULL ? null : $value);
	}
812756
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

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

        return $value->id;
    }
914421
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

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

        return $value->id;
    }
859080
public function reverseTransform($value)
    {
        if (null === $value || '' === $value) {
            return null;
        }

        if (!is_scalar($value)) {
            throw new TransformationFailedException('Expected a scalar.');
        }

        $entity = $this->repository->find($value);

        if (null === $entity) {
            throw new TransformationFailedException(
                sprintf('Entity %s with identifier "%s" not found.', $this->className, $value)
            );
        }

        return $entity;
    }
663703
public function transform($id)
    {
        if (null === $id) {
            return null;
        } else if (is_string($id)) {
            /** @var Group|null $entity */
            $entity = $this->om->getRepository('FOMUserBundle:Group')
                ->findOneBy(array('id' => $id));
            return $entity;
        } elseif (is_array($id)) {
            if (count($id) === 0) {
                return null;
            }
            $result = new ArrayCollection();
            foreach($id as $value) {
                $group = $this->om->getRepository('FOMUserBundle:Group')
                    ->findOneBy(array('id' => $value));
                if ($group !== null) {
                    $result->add($group);
                }
            }
            return $result;
        } else {
            return null;
        }
    }
434036
public function reverseTransform($value)
    {
        if (!$value) {
            return null;
        }

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

        if (!$value || !$this->parseUrl($value)) {
            throw new TransformationFailedException('Empty or invalid string.');
        }

        $video = $this->videoManager->findByVideoId($this->videoId);

        if (!$video) {
            $video = $this->videoManager->createVideo();

            $video->setVideoId($this->videoId);
            $video->setType($this->videoType);
            $video->setUrl($value);
        }

        return $video;
    }
583300
public function get($id)
    {
        $resolved = $this->getResolved($id);

        return $resolved ? $resolved->getInnerExtension() : null;
    }
296471
public static function convertKey($id)
    {
        if (is_string($id) && strlen($id) === 24 && ctype_xdigit($id)) {
            return new ObjectID($id);
        }

        return $id;
    }
915027
public static function getById($id)
    {
        $result = null;
        $info = CldrData::getLanguageInfo($id);
        if (isset($info)) {
            $result = new Language($info);
        }

        return $result;
    }
1337826
public function reverseTransform($id)
    {
        if ('' === $id || null === $id) {
            return;
        }

        if (!is_numeric($id)) {
            throw new UnexpectedTypeException($id, 'numeric'.$id);
        }

        $entity = $this->entityManager->getRepository($this->class)->findOneById($id);

        if ($entity === null) {
            throw new TransformationFailedException(sprintf('The entity with key "%s" could not be found', $id));
        }

        return $entity;
    }
1205122
public function deleteAction($id)
    {
        $request = $this->getRequest();
        $id = $request->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id: %s', $id));
        }

        $this->checkParentChildAssociation($request, $object);

        $this->admin->checkAccess('delete', $object);

        $preResponse = $this->preDelete($request, $object);
        if (null !== $preResponse) {
            return $preResponse;
        }

        if ('DELETE' === $this->getRestMethod()) {
            // check the csrf token
            $this->validateCsrfToken('sonata.delete');

            $objectName = $this->admin->toString($object);

            try {
                $this->admin->delete($object);

                if ($this->isXmlHttpRequest()) {
                    return $this->renderJson(['result' => 'ok'], 200, []);
                }

                $this->addFlash(
                    'sonata_flash_success',
                    $this->trans(
                        'flash_delete_success',
                        ['%name%' => $this->escapeHtml($objectName)],
                        'SonataAdminBundle'
                    )
                );
            } catch (ModelManagerException $e) {
                $this->handleModelManagerException($e);

                if ($this->isXmlHttpRequest()) {
                    return $this->renderJson(['result' => 'error'], 200, []);
                }

                $this->addFlash(
                    'sonata_flash_error',
                    $this->trans(
                        'flash_delete_error',
                        ['%name%' => $this->escapeHtml($objectName)],
                        'SonataAdminBundle'
                    )
                );
            }

            return $this->redirectTo($object);
        }

        // NEXT_MAJOR: Remove this line and use commented line below it instead
        $template = $this->admin->getTemplate('delete');
        // $template = $this->templateRegistry->getTemplate('delete');

        return $this->renderWithExtraParams($template, [
            'object' => $object,
            'action' => 'delete',
            'csrf_token' => $this->getCsrfToken('sonata.delete'),
        ], null);
    }