Transforms a string (number) to an object (chat).

@param  string $chatID
@return Chat|null
@throws TransformationFailedException if object (chat) is not found.
349562
public function reverseTransform($chatID)
    {
        // no chat number? It's optional, so that's ok
        if (!$chatID) {
            return;
        }

        $reChat = $this->em->getRepository('SopinetChatBundle:Chat');
        $chat = $reChat->find($chatID);

        if (null === $chat) {
            // causes a validation error
            // this message is not shown to the user
            // see the invalid_message option
            throw new TransformationFailedException(sprintf(
            'An chat with id "%s" does not exist!',
                $chatID
            ));
        }

        return $chat;
    }
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;
    }
1093484
public function reverseTransform($value)
    {
        if (empty($value)) {
            return null;
        }

        if (!is_numeric($value)) {
            throw new TransformationFailedException(
                sprintf('Expected a numeric, got %s instead', gettype($value))
            );
        }

        return Value::fromTimestamp($value);
    }
14768
public Chat chatWith(EntityBareJid jid) {
        Chat chat = chats.get(jid);
        if (chat == null) {
            synchronized (chats) {
                // Double-checked locking.
                chat = chats.get(jid);
                if (chat != null) {
                    return chat;
                }
                chat = new Chat(connection(), jid);
                chats.put(jid, chat);
            }
        }
        return chat;
    }
733016
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

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

        return $value->languageCode;
    }
1268923
public function readMessage($messageId = null)
    {
        if (!is_null($messageId)) {
            $message = $this->message->with(['sender', 'conversation'])->find($messageId);

            if ($message->coversation->user_one == $this->authUserId || $message->coversation->user_two == $this->authUserId) {
                return $message;
            }
        }

        return false;
    }
722554
public function transform($value)
    {
        if ($value === null) {
            return null;
        }

        if (!$value instanceof $this->enumClass) {
            throw new TransformationFailedException(sprintf(
                'Expected instance of "%s". Got "%s".',
                $this->enumClass,
                \is_object($value) ? \get_class($value) : \gettype($value)
            ));
        }

        return $value->getValue();
    }
704120
public function get(int $conversationId, int $attachmentId): Attachment
    {
        $conversationResource = $this->restClient->getResource(
            Attachment::class,
            sprintf('/v2/conversations/%d/attachments/%d/data', $conversationId, $attachmentId)
        );

        return $conversationResource->getEntity();
    }
118219
public function reverseTransform($cID)
    {
        if (!is_numeric($cID) || $cID == 0) {
            return null;
        }

        $rep = $this->entityManager->getRepository('Concrete\Core\Page\Page');

        $c = $rep->find($cID);
        if (!is_object($c) || $c->isError()) {
            throw new TransformationFailedException('Invalid page ID.');
        }

        return $c;
    }
367455
def get_chat_from_id(self, chat_id):
        
        chat = self.wapi_functions.getChatById(chat_id)
        if chat:
            return factory_chat(chat, self)

        raise ChatNotFoundError("Chat {0} not found".format(chat_id))
467948
public function getChatId($chat_id = null) {
        try {
            if ($chat_id)
                return $chat_id;

            if( isset($this->result->message) ) {
                return $this->result->message->chat->id;
            } elseif ( isset($this->result->inline_query) ) {
                return $this->result->inline_query->from->id;
            } else {
                throw new \Exception("Error Processing Request", 1);
            }
        } catch (\Exception $e) {
            error_log($e->getMessage());
        }
    }
490142
public function transform($value): ?int
    {
        if (null === $value) {
            return null;
        }

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

        return $value->id;
    }
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);
        }
    }
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;
    }
443402
public function reverseTransform($value): ?APIRoleAssignment
    {
        if (empty($value)) {
            return null;
        }

        try {
            return $this->roleService->loadRoleAssignment($value);
        } catch (NotFoundException $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }
    }
344032
public function reverseTransform($id)
    {
        if (!$id) {
            return null;
        }
        if($this->sinDigito) {
            $id=trim(substr($id,0,-1));
        }
        $id=intval($id);
        $object = $this->om
            ->getRepository($this->objectClass)
            ->find($id);

        if (null === $object) {
            throw new TransformationFailedException(sprintf(
                'Object class %s con id "%s" no existe!',
                $this->objectClass, $id
            ));
        }

        return $object;
    }
1344078
public function getConversationMessageById($conversationId)
    {
        if ($this->conversation->checkUserExist($this->userId, $conversationId)) {
            $channel = $this->getChannelName($conversationId, 'chat_room');

            return $this->conversation->getConversationMessageById($conversationId, $this->userId, $channel);
        }

        abort(404);
    }