Newscoop\Service\Implementation\TemplateSearchServiceDoctrine::getErrorPage PHP Method

getErrorPage() public method

Get the page for error to be used as a template.
public getErrorPage ( Issue | Int $issue, Output | integer | string $output ) : string
$issue Newscoop\Entity\Issue | Int The issue object or the id of the issue for whom the template is needed.
$output Newscoop\Entity\Output | integer | string The object Output, the id or the Name of the Output for whom the template is needed.
return string The full path of the template.
    public function getErrorPage($issue, $output)
    {
        /* @var $issue Issue */
        $issueId = $issue;
        if ($issue instanceof Issue) {
            $issueId = $issue->getId();
        } else {
            $issue = $this->getIssueService()->getById($issueId);
        }
        $publicationId = $issue->getPublicationId();
        $outputId = $output;
        if ($output instanceof Output) {
            $outputId = $output->getId();
        }
        $em = $this->getManager();
        $q = $em->createQueryBuilder();
        $q->select(array('oi', 'ot'))->from(OutputSettingsTheme::NAME, 'ot')->from(OutputSettingsIssue::NAME_1, 'oi')->where('ot.themePath = oi.themePath')->andWhere('ot.publication = :publication')->andWhere('ot.output = :output')->andWhere('oi.output = :output')->andWhere('oi.issue = :issue')->setParameter('output', $outputId)->setParameter('issue', $issueId)->setParameter('publication', $publicationId);
        $results = $q->getQuery()->getResult();
        if (count($results) < 2) {
            return '';
        }
        /* @var $outputSettingTheme OutputSettingsTheme */
        list(, $outputSettingTheme) = each($results);
        /* @var $outputSettingIssue OutputSettingsIssue */
        list(, $outputSettingIssue) = each($results);
        if (!is_null($resource = $outputSettingIssue->getErrorPage())) {
            return $this->getResourceFullPath($resource);
        }
        return $this->getResourceFullPath($outputSettingTheme->getErrorPage());
    }