Newscoop\Entity\Repository\SnippetRepository::checkIfSnippetIsDisabled PHP Method

checkIfSnippetIsDisabled() protected method

Check if a Snippet is disabled Internal use only
protected checkIfSnippetIsDisabled ( Doctrine\ORM\QueryBuilder $queryBuilder, mixed $result, string $show )
$queryBuilder Doctrine\ORM\QueryBuilder
$result mixed
$show string
    protected function checkIfSnippetIsDisabled($queryBuilder, $result, $show)
    {
        if ($show == 'enabled' && is_null($result)) {
            $expr = $queryBuilder->getDQLPart('where')->getParts();
            $newExpr = new \Doctrine\ORM\Query\Expr\Andx();
            $newExpr->addMultiple(preg_grep("/\\bsnippet.enabled\\b/i", $expr, PREG_GREP_INVERT));
            $queryBuilder->resetDQLPart('where');
            $queryBuilder->add('where', $newExpr);
            if (!is_null($queryBuilder->getQuery()->getOneOrNullResult())) {
                throw new \Exception('Result was found but disabled.');
            }
        }
        return $result;
    }