Newscoop\GimmeBundle\Controller\TopicsController::getTopicsArticlesAction PHP Метод

getTopicsArticlesAction() публичный Метод

Returns array with articles under "items" key and requested topic "id" and "title"
public getTopicsArticlesAction ( Request $request, $id, $language )
$request Symfony\Component\HttpFoundation\Request
    public function getTopicsArticlesAction(Request $request, $id, $language)
    {
        $em = $this->container->get('em');
        $publication = $this->get('newscoop_newscoop.publication_service')->getPublication()->getId();
        $paginatorService = $this->get('newscoop.paginator.paginator_service');
        $paginatorService->setUsedRouteParams(array('id' => $id, 'language' => $language));
        $language = $em->getRepository('Newscoop\\Entity\\Language')->findOneByCode($language);
        $query = $em->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic')->getArticlesQueryByTopicIdAndLanguage($id, $language->getCode());
        $topic = $query->getArrayResult();
        if (empty($topic)) {
            throw new NotFoundHttpException('Result was not found.');
        }
        $articles = $em->getRepository('Newscoop\\Entity\\Article')->getArticlesForTopic($publication, $id);
        $paginator = $this->get('newscoop.paginator.paginator_service');
        $articles = $paginator->paginate($articles, array('distinct' => false));
        $allItems = array_merge(array('id' => $topic[0]['id'], 'title' => $topic[0]['title']), $articles);
        return $allItems;
    }