public function checkUnreadAction(Request $request, $access)
    {
        $em = $this->getDoctrineManager();
        $sm = $this->container->get('sakonnin.messages');
        $user = $this->getUser();

        $repo = $em->getRepository('BisonLabSakonninBundle:Message');
        $messages = $sm->getMessagesForLoggedIn(array('state' => 'UNREAD'));
        if ($messages) {
            return $this->returnRestData($request, array('amount' => count($messages)));
        }
        // return $this->returnRestData($request, false);
        return $this->returnRestData($request, array('amount' => 0));
    }
public function checkUnreadAction(Request $request, $access)
    {
        $em = $this->getDoctrineManager();
        $sm = $this->container->get('sakonnin.messages');
        $user = $this->getUser();

        $repo = $em->getRepository('BisonLabSakonninBundle:Message');
        $messages = $sm->getMessagesForLoggedIn(array('state' => 'UNREAD'));
        if ($messages) {
            return $this->returnRestData($request, array('amount' => count($messages)));
        }
        // return $this->returnRestData($request, false);
        return $this->returnRestData($request, array('amount' => 0));
    }
public function checkUnreadAction ( Request $ request , $ access ) { $ em = $ this -> getDoctrineManager ( ) ; $ sm = $ this -> container -> get ( 'sakonnin.messages' ) ; $ user = $ this -> getUser ( ) ; $ repo = $ em -> getRepository ( 'BisonLabSakonninBundle:Message' ) ; $ messages = $ sm -> getMessagesForLoggedIn ( array ( 'state' => 'UNREAD' ) ) ; if ( $ messages ) { return $ this -> returnRestData ( $ request , array ( 'amount' => count ( $ messages ) ) ) ; } // return $this->returnRestData($request, false); return $ this -> returnRestData ( $ request , array ( 'amount' => 0 ) ) ; }
Check for unread messages

@Route("/check_unread/", name="check_unread", methods={"GET"})
Check for unread messages