Inheritance: extends AbstractEntity
コード例 #1
0
 public function let(IssueServiceInterface $issueService, Issue $issue, CacheService $cacheService, PublicationService $publicationService, Publication $publication, EntityManager $em, Registry $doctrine, EntityRepository $repository, Output $output, OutputSettingsIssue $issueOutput)
 {
     $issueService->getIssue()->willReturn($issue);
     $publicationService->getPublication()->willReturn($publication);
     $doctrine->getManager()->willReturn($em);
     $em->getRepository(Argument::exact('Newscoop\\Entity\\Output'))->willReturn($repository);
     $repository->findBy(array('name' => 'Web'))->willReturn(array($output));
     $em->getRepository(Argument::exact('Newscoop\\Entity\\Output\\OutputSettingsIssue'))->willReturn($repository);
     $repository->findBy(array('issue' => 1, 'output' => 1))->willReturn(array($issueOutput));
     $issue->getId()->willReturn(1);
     $issue->getNumber()->willReturn(10);
     $issue->getName()->willReturn("May 2014");
     $issue->getShortName()->willReturn("may2014");
     $issue->getLanguageId()->willReturn(1);
     $output->getId()->willReturn(1);
     $output->getName()->willReturn('Web');
     $this->beConstructedWith($issueService, $cacheService, $publicationService, $em);
 }
コード例 #2
0
 /**
  * Provides the Output Settings Issue for the provided issue and output
  *
  * @param Issue|int $issue
  * 		The issue to be searched, not null, not empty.
  * @param Output|int|string $output
  * 		The output to be searched, not null, not empty.
  *
  * @return array Newscoop\Entity\Output\OutputSettingsIssue
  * 		The Output Setting, NULL if no Output Setting could be found for the provided issue.
  */
 public function findByIssueAndOutput($issue, $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 Issue object is supplied */
     /* @var $issue Issue */
     $issueId = $issue;
     if ($issue instanceof Issue) {
         $issueId = $issue->getId();
     }
     $em = $this->getManager();
     $repository = $em->getRepository($this->entityClassName);
     $resources = $repository->findBy(array('issue' => $issueId, 'output' => $outputId));
     if (!empty($resources)) {
         return $resources[0];
     }
     return NULL;
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
 public function setId($id)
 {
     $this->__load();
     return parent::setId($id);
 }
コード例 #5
0
ファイル: ThemesService.php プロジェクト: alvsgithub/Newscoop
 /**
  * Finds output for issue by issue and output
  *
  * @param Issue  $issue  Issue object
  * @param Output $output Output object
  *
  * @return string|null
  */
 public function findByIssueAndOutput($issue, $output)
 {
     $outputId = $output;
     if ($output instanceof Output) {
         $outputId = $output->getId();
     }
     $issueId = $issue;
     if ($issue instanceof Issue) {
         $issueId = $issue->getId();
     }
     $resources = $this->em->getRepository('Newscoop\\Entity\\Output\\OutputSettingsIssue')->findBy(array('issue' => $issueId, 'output' => $outputId));
     if (!empty($resources)) {
         return $resources[0];
     }
     return null;
 }
コード例 #6
0
 /**
  * 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());
 }