public getSectionPage ( |
||
$section | The section object or the id of the issue for whom the template is needed. | |
$output | The object Output, the id or the Name of the Output for whom the template is needed. | |
Résultat | string | The full path of the template. |
public function getSectionPage($section, $output)
{
/** Get the id if an Output object tis supplied */
/* @var $output Output */
$outputId = $output;
if ($output instanceof Output) {
$outputId = $output->getId();
}
/** Get the id if an Section object tis supplied */
/* @var $section Section */
$sectionId = $section;
if ($section instanceof Section) {
$sectionId = $section->getId();
}
/* @var $outputSettingSection OutputSettingsSection */
$outputSettingSection = $this->getOutputSettingSectionService()->findBySectionAndOutput($sectionId, $outputId);
if (!is_null($outputSettingSection) && !is_null($resource = $outputSettingSection->getSectionPage())) {
return $this->getResourceFullPath($resource);
}
if (!$section instanceof Section) {
$section = $this->getSectionService()->findById($section);
}
/* @var $issue Issue */
$issue = $section->getIssue();
$issueId = $issue->getId();
$publicationId = $issue->getPublicationId();
$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.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->getSectionPage())) {
return $this->getResourceFullPath($resource);
}
return $this->getResourceFullPath($outputSettingTheme->getSectionPage());
}