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

@param string $id

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

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

        $view = $this->om
            ->getRepository('VictoireCoreBundle:View')
            ->findOneBy(['id' => $id]);

        if (null === $view) {
            throw new TransformationFailedException(sprintf(
                'View #"%s" not found !',
                $id
            ));
        }

        return $view;
    }
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;
    }
348198
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof Value) {
            throw new TransformationFailedException(
                sprintf('Expected a %s, got %s instead', Value::class, gettype($value))
            );
        }

        if (null === $value->date) {
            return null;
        }

        return $value->date->getTimestamp();
    }
534153
public function transformInto($id)
    {
        $newType = NodeType::find($id);

        if (is_null($newType))
        {
            throw new \RuntimeException('Node type does not exist');
        }

        $sourceAttributes = $this->parseSourceAttributes();

        $this->flushSources();

        $this->transformNodeType($newType);

        $this->remakeSources($newType);

        $this->fill($sourceAttributes);

        $this->save();
    }
1296978
public function reverseTransform($path)
    {
        if (!$path) {
            return;
        }

        $document = $this->dm->find(null, $path);

        if (!$document) {
            throw new TransformationFailedException(sprintf('Could not transform path "%s" to document. Path not found.', $path));
        }

        return $document;
    }
602939
public function reverseTransform($service_id)
    {
        if (!$service_id) {
            return null;
        }

        $service = $this->om
            ->getRepository('ACSACSPanelBundle:Service')
            ->findOneBy(array('id' => $service_id))
        ;

        if (null === $service) {
            throw new TransformationFailedException(sprintf(
                'A service with id "%s" does not exist!',
                $service_id
            ));
        }

        return $service;
    }
765905
static public function createObjectID($id=null)
    {
        if ($id === null) {
            return new \MongoDB\BSON\ObjectId;
        }

        try {
            return new \MongoDB\BSON\ObjectId($id);
        } catch(\MongoDB\Driver\Exception\InvalidArgumentException $e) {
        }

        throw new Exception('Invalid ObjectId');
    }
1215068
public function reverseTransform($value): ?APISection
    {
        if (empty($value)) {
            return null;
        }

        try {
            return $this->sectionService->loadSection($value);
        } catch (NotFoundException $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }
    }
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;
    }
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;
    }
469541
public function get($id)
    {
        if (!is_string($id)) {
            throw new ContainerException('$id must be a string');
        }

        if (!isset($this->definitions[$id])) {
            throw new NotFoundException("Unresolvable ".$id);
        }

        return $this->definitions[$id];
    }
1206162
public function getChild(string $id)
    {
        $menuItem = $this->menuItem->getChild($id);

        return $menuItem ? $this->generateMenuItem($menuItem) : null;
    }
1281119
public function findNavigation( $id = null )
    {
        $renderList = $this->findRenderList( $id );

        if ( null !== $id && empty( $renderList ) )
        {
            return null;
        }

        $convert = new ConvertToNavigation( $renderList );
        return null === $id ? $convert->getRoot() : $convert->getLast();
    }
516069
public function view($id = null) {
        $cmsTermTaxonomy = $this->CmsTermTaxonomy->get($id, [
            'contain' => ['CmsTerm', 'CmsTermRelation']
        ]);
        $this->set('cmsTermTaxonomy', $cmsTermTaxonomy);
        $this->set('_serialize', ['cmsTermTaxonomy']);
    }
30113
public function transform($value)
    {
        if ($value === null || $value == '') {
            return null;
        }
        if (!($value instanceof Page)) {
            throw new TransformationFailedException('Expected an instance of a concrete5 page object.');
        }
        return intval($value->getCollectionID());
    }
575953
protected function escapeId($id)
    {
        if (!$this->replace) {
            return $id;
        }

        return str_replace(array_keys($this->replace), array_values($this->replace), $id);
    }
1265431
public function show($id)
    {
        $item = $this->repo->getById($id);

        if ( ! $item)
        {
            return $this->respondNotFound();
        }

        return $this->response->item($item, new $this->transformerClass);
    }