/** * Add the additional query conditions returned by the QueryRestrictionBuilder * to the current query and return the original set of conditions so that they * can be restored after the query has been built/executed. * * @return \Doctrine\DBAL\Query\Expression\CompositeExpression|mixed */ protected function addAdditionalWhereConditions() { $originalWhereConditions = $this->concreteQueryBuilder->getQueryPart('where'); $expression = $this->restrictionContainer->buildExpression($this->getQueriedTables(), $this->expr()); // This check would be obsolete, as the composite expression would not add empty expressions anyway // But we keep it here to only clone the previous state, in case we really will change it. // Once we remove this state preserving functionality, we can remove the count check here // and just add the expression to the query builder. if ($expression->count() > 0) { if ($originalWhereConditions instanceof CompositeExpression) { // Save the original query conditions so we can restore // them after the query has been built. $originalWhereConditions = clone $originalWhereConditions; } $this->concreteQueryBuilder->andWhere($expression); } // @todo add hook to be able to add additional restrictions return $originalWhereConditions; }
/** * Add delete restriction if not disabled * * @param QueryRestrictionContainerInterface $restrictions * @return void */ protected function addDeleteRestriction(QueryRestrictionContainerInterface $restrictions) { if (!$this->disableDeleteClause) { $restrictions->add(GeneralUtility::makeInstance(DeletedRestriction::class)); } }