public function showAction(Request $request, $access, $id)
    {
        $em = $this->getDoctrineManager();
        // Hack. The contextGetAction in CommonBundle is not as smart as it
        // looks.
        $message = null;
        if ($id instanceof Message) {
            $message = $id;
        } elseif (is_numeric($id)) {
            $message = $em->getRepository('BisonLabSakonninBundle:Message')
                    ->find($id);
        } else {
            $message = $em->getRepository('BisonLabSakonninBundle:Message')
                    ->findOneBy(array('message_id' => $id));
        }
        if (!$message) {
            return $this->returnNotFound($request, 'Unable to find Message.');
        }
        $this->denyAccessUnlessGranted('show', $message);
        // If it's shown to receiver, it's read.
        $sm = $this->container->get('sakonnin.messages');
        $user = $this->getUser();
        // Not sure I want to set READ automatically. But UNREAD/READ is not
        // archived, which the users should set themselves.
        if ($message->getTo() == $user->getId()) {
            $message->setState("READ");
            $em = $this->getDoctrineManager();
            $em->flush();
        }
        if ($this->isRest($access)) {
            return $this->returnRestData($request, $messages, array('html' =>'BisonLabSakonninBundle:Message:_show.html.twig'));
        }
        return $this->render('BisonLabSakonninBundle:Message:show.html.twig',
            array('entity' => $message));
    }
public function showAction(Request $request, $access, $id)
    {
        $em = $this->getDoctrineManager();
        // Hack. The contextGetAction in CommonBundle is not as smart as it
        // looks.
        $message = null;
        if ($id instanceof Message) {
            $message = $id;
        } elseif (is_numeric($id)) {
            $message = $em->getRepository('BisonLabSakonninBundle:Message')
                    ->find($id);
        } else {
            $message = $em->getRepository('BisonLabSakonninBundle:Message')
                    ->findOneBy(array('message_id' => $id));
        }
        if (!$message) {
            return $this->returnNotFound($request, 'Unable to find Message.');
        }
        $this->denyAccessUnlessGranted('show', $message);
        // If it's shown to receiver, it's read.
        $sm = $this->container->get('sakonnin.messages');
        $user = $this->getUser();
        // Not sure I want to set READ automatically. But UNREAD/READ is not
        // archived, which the users should set themselves.
        if ($message->getTo() == $user->getId()) {
            $message->setState("READ");
            $em = $this->getDoctrineManager();
            $em->flush();
        }
        if ($this->isRest($access)) {
            return $this->returnRestData($request, $messages, array('html' =>'BisonLabSakonninBundle:Message:_show.html.twig'));
        }
        return $this->render('BisonLabSakonninBundle:Message:show.html.twig',
            array('entity' => $message));
    }
public function showAction ( Request $ request , $ access , $ id ) { $ em = $ this -> getDoctrineManager ( ) ; // Hack. The contextGetAction in CommonBundle is not as smart as it // looks. $ message = null ; if ( $ id instanceof Message ) { $ message = $ id ; } elseif ( is_numeric ( $ id ) ) { $ message = $ em -> getRepository ( 'BisonLabSakonninBundle:Message' ) -> find ( $ id ) ; } else { $ message = $ em -> getRepository ( 'BisonLabSakonninBundle:Message' ) -> findOneBy ( array ( 'message_id' => $ id ) ) ; } if ( ! $ message ) { return $ this -> returnNotFound ( $ request , 'Unable to find Message.' ) ; } $ this -> denyAccessUnlessGranted ( 'show' , $ message ) ; // If it's shown to receiver, it's read. $ sm = $ this -> container -> get ( 'sakonnin.messages' ) ; $ user = $ this -> getUser ( ) ; // Not sure I want to set READ automatically. But UNREAD/READ is not // archived, which the users should set themselves. if ( $ message -> getTo ( ) == $ user -> getId ( ) ) { $ message -> setState ( "READ" ) ; $ em = $ this -> getDoctrineManager ( ) ; $ em -> flush ( ) ; } if ( $ this -> isRest ( $ access ) ) { return $ this -> returnRestData ( $ request , $ messages , array ( 'html' => 'BisonLabSakonninBundle:Message:_show.html.twig' ) ) ; } return $ this -> render ( 'BisonLabSakonninBundle:Message:show.html.twig' , array ( 'entity' => $ message ) ) ; }
Finds and displays a Message entity.

@Route("/{id}", name="message_show", methods={"GET"})
Finds and displays a Message entity .