Ojs\OAIBundle\Controller\JournalController::recordsAction PHP Method

recordsAction() public method

Action for the records verb
public recordsAction ( Request $request ) : Response
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\Response
    public function recordsAction(Request $request)
    {
        /** @var EntityManager $em */
        $em = $this->getDoctrine()->getManager();
        $slug = $request->get('slug', false);
        $setParam = $request->get('set', false);
        $fromParam = $request->get('from', false);
        $untilParam = $request->get('until', false);
        $this->throw404IfNotFound($slug);
        $builder = $em->createQueryBuilder();
        $builder->select('article')->from('OjsJournalBundle:Article', 'article');
        $builder->join('article.journal', 'journal', 'WITH');
        $builder->where($builder->expr()->eq('article.status', ArticleStatuses::STATUS_PUBLISHED));
        $builder->andWhere($builder->expr()->eq('journal.slug', ':slug'))->setParameter('slug', $slug);
        if ($fromParam) {
            $from = new \DateTime();
            $from->setTimestamp(strtotime($fromParam));
            $comparison = $builder->expr()->gte('article.created', ':from');
            $builder->andWhere($comparison)->setParameter('from', $from);
        }
        if ($untilParam) {
            $until = new \DateTime();
            $until->setTimestamp(strtotime($until));
            $comparison = $builder->expr()->lte('article.created', ':until');
            $builder->andWhere($comparison)->setParameter('until', $until);
        }
        $fileCache = $this->get('file_cache');
        $resumptionToken = $request->get('resumptionToken');
        if ($resumptionToken) {
            $token = $fileCache->fetch($resumptionToken);
            $currentPage = (int) $token['page'];
            $setParam = $token['set'];
        } else {
            $currentPage = 1;
        }
        $generatedToken = md5(StringHelper::generateKey());
        $fileCache->save($generatedToken, $currentPage + 1, 60 * 60 * 24);
        if ($setParam) {
            $builder->join('article.section', 'section', 'WITH');
            $condition = $builder->expr()->eq('section.id', ':section');
            $builder->andWhere($condition)->setParameter('section', $setParam);
        }
        $paginator = $this->get('knp_paginator');
        /** @var AbstractPagination $records */
        $records = $paginator->paginate($builder->getQuery(), $currentPage, 100);
        $data = ['specType' => 'section', 'records' => $records, 'currentPage' => $currentPage, 'resumptionToken' => $generatedToken, 'metadataPrefix' => $request->get('metadataPrefix', 'oai_dc'), 'isLast' => $records->getTotalItemCount() >= $currentPage * 100];
        return $this->response('OjsOAIBundle:Default:records.xml.twig', $data);
    }