Newscoop\Service\Implementation\OutputSettingSectionServiceDoctrine::findBySectionAndOutput PHP Method

findBySectionAndOutput() public method

Provides the Output Settings that has the provided Section.
public findBySectionAndOutput ( Section | integer $section, Output | integer | string $output ) : Newscoop\Entity\OutputSettingsSection
$section Newscoop\Entity\Section | integer The section to be searched, not null, not empty.
$output Newscoop\Entity\Output | integer | string
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;
    }