Newscoop\Service\Implementation\ThemeManagementServiceLocal::getThemePublication PHP Method

getThemePublication() public method

Get the publication of a theme, and optionally output
public getThemePublication ( Theme $theme, Output $output = null ) : Publication
$theme Newscoop\Entity\Theme
$output Newscoop\Entity\Output
return Newscoop\Entity\Publication
    public function getThemePublication($theme, $output = null)
    {
        $pathRsc = $this->getSyncResourceService()->getThemePath($theme->getPath());
        $em = $this->getManager();
        $qb = $em->createQueryBuilder();
        $qb->select('th')->from(OutputSettingsTheme::NAME, 'th');
        $qb->where('th.themePath = :themePath');
        $qb->setParameter('themePath', $pathRsc);
        if (!is_null($output)) {
            $qb->andWhere('th.output = :output');
            $qb->setParameter('output', $output);
        }
        $result = current($qb->getQuery()->getResult());
        if ($result) {
            return $result->getPublication();
        }
        return null;
    }