/** * Provides the Output Settings that has the provided Section. * * @param Section|int $section * The section to be searched, not null, not empty. * @param Output|int|string $output * * @return Newscoop\Entity\OutputSettingsSection * The Output Setting, NULL if no Output Setting could be found for the provided section. */ public function findBySectionAndOutput($section, $output) { /** Get the id if an Output object is supplied */ /* @var $output Output */ $outputId = $output; if ($output instanceof Output) { $outputId = $output->getId(); } /** Get the id if an Section object is supplied */ /* @var $section Section */ $sectionId = $section; if ($section instanceof Section) { $sectionId = $section->getId(); } $em = $this->getManager(); $repository = $em->getRepository($this->entityClassName); $resources = $repository->findBy(array('section' => $sectionId, 'output' => $outputId)); if (!empty($resources)) { return $resources[0]; } return NULL; }
public function getId() { $this->__load(); return parent::getId(); }
/** * Get the page for article * to be used as a template. * * @param Section|Int $section * The section object or the id of the issue for whom the template is needed. * @param Output|int|string $output * 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 getArticlePage($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->getArticlePage())) { 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->getArticlePage())) { return $this->getResourceFullPath($resource); } return $this->getResourceFullPath($outputSettingTheme->getArticlePage()); }
/** * Test if has given section * * @param Newscoop\Subscription\Section $section * @param array $languages * @return bool */ private function hasSection(\Newscoop\Entity\Section $section, array $languages) { foreach ($this->sections as $s) { if ($s->getSectionNumber() == $section->getNumber()) { if (!$s->hasLanguage()) { return true; } else { if (empty($languages)) { $s->setLanguage(null); return true; } else { if ($s->getLanguage() == $section->getLanguage()) { return true; } } } } } return false; }