Bundle/BlogBundle/Controller/BlogController.php
protected function getBlog(Request $request, $blogId)
    {
        /** @var BlogRepository $blogRepo */
        $blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog');

        if ($blogId) {
            $blog = $blogRepo->find($blogId);
        } else {
            $blogs = $blogRepo->joinTranslations($request->getLocale())->run();
            $blog = reset($blogs);
        }

        return $blog;
    }
protected function getBlog(Request $request, $blogId)
    {
        /** @var BlogRepository $blogRepo */
        $blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog');

        if ($blogId) {
            $blog = $blogRepo->find($blogId);
        } else {
            $blogs = $blogRepo->joinTranslations($request->getLocale())->run();
            $blog = reset($blogs);
        }

        return $blog;
    }
protected function getBlog ( Request $ request , $ blogId ) { /** @var BlogRepository $blogRepo */ $ blogRepo = $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'VictoireBlogBundle:Blog' ) ; if ( $ blogId ) { $ blog = $ blogRepo -> find ( $ blogId ) ; } else { $ blogs = $ blogRepo -> joinTranslations ( $ request -> getLocale ( ) ) -> run ( ) ; $ blog = reset ( $ blogs ) ; } return $ blog ; }
Get Blog from id if defined.
If not return the first Blog.

@param Request $request
@param $blogId

@return Blog|false
Get Blog from id if defined . If not return the first Blog .