Newscoop\Entity\Repository\SnippetRepository::getSnippetQueryBuilder PHP Метод

getSnippetQueryBuilder() защищенный Метод

This internal function is used by almost all Repository functions, it allows for more consistency. The rest of the doc also applies to the functions using it. Returns all Snippets. If the SnippetTemplate is disabled, the Snippets depending on it won't be returned. By Default all Snippets that are Disabled themselves are not returned.
protected getSnippetQueryBuilder ( string $show, $templateEnabled = true ) : Doctrine\ORM\Querybuilder
$show string Define which Snippets to return, 'enabled' | 'disabled' | 'all'
Результат Doctrine\ORM\Querybuilder $queryBuilder
    protected function getSnippetQueryBuilder($show, $templateEnabled = true)
    {
        if (!in_array($show, array('enabled', 'disabled', 'all'))) {
            $show = 'enabled';
        }
        $queryBuilder = $this->createQueryBuilder('snippet');
        if ($templateEnabled) {
            // by default a Template should always be enabled
            $queryBuilder->join('snippet.template', 'template')->andWhere('template.enabled = 1');
        }
        if ($show == 'enabled') {
            $queryBuilder->andWhere('snippet.enabled = 1');
        }
        if ($show == 'disabled') {
            $queryBuilder->andWhere('snippet.enabled = 0');
        }
        return $queryBuilder;
    }