*/ class BackendUserGroupRepository extends Repository { public const TABLE_NAME = 'be_groups'; protected $defaultOrderings = [ 'title' => QueryInterface::ORDER_ASCENDING, ]; /** * Overwrite createQuery to don't respect enable fields */ public function createQuery(): QueryInterface { $query = parent::createQuery(); $query->getQuerySettings()->setIgnoreEnableFields(true); return $query; } /** * Get QueryBuilder without restrictions for table be_groups */ public function getQueryBuilder(bool $removeRestrictions = true): QueryBuilder { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE_NAME); if ($removeRestrictions === true) { $queryBuilder->getRestrictions()->removeAll(); } return $queryBuilder; } /** * Finds Backend Usergroups on a given list of uids */ public function findByUidList(array $uidList): array { $query = $this->createQuery(); // being explicit here, albeit `Typo3DbQueryParser::parseDynamicOperand` uses prepared parameters $uidList = array_map(intval(...), $uidList); $query->matching($query->in('uid', $uidList)); return $query->execute(true); } /** * Preforms a query on be_groups, matching the field title with like * @throws InvalidQueryException */ public function findByFilter(BackendUserGroup $backendUserGroupDto): QueryResult { $constraints = []; $query = $this->createQuery(); $query->setOrderings(['title' => QueryInterface::ORDER_ASCENDING]); if ($backendUserGroupDto->getTitle() !== '') { $searchConstraints = []; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE_NAME); $searchConstraints[] = $query->like( 'title', '%' . $queryBuilder->escapeLikeWildcards($backendUserGroupDto->getTitle()) . '%' ); if (MathUtility::canBeInterpretedAsInteger($backendUserGroupDto->getTitle())) { $searchConstraints[] = $query->equals('uid', (int)$backendUserGroupDto->getTitle()); } if (count($searchConstraints) >= 2) { $constraints[] = $query->logicalOr(...$searchConstraints); } else { $constraints = $searchConstraints; } } $constraints = $this->eventDispatcher->dispatch( new AfterBackendGroupListConstraintsAssembledFromDemandEvent( $backendUserGroupDto, $query, $constraints ) )->constraints; $query->matching($query->logicalAnd(...$constraints)); /** @var QueryResult $result */ $result = $query->execute(); return $result; } }