*/ class UtmTaxonomyRepository extends CommonRepository { public function getTableAlias(): string { return 'ut'; } /** * True when another taxonomy already uses this name. A taxonomy being edited never collides with itself. */ public function nameExists(string $name, ?int $ignoreId = null): bool { if ('' === $name) { return false; } $qb = $this->createQueryBuilder($this->getTableAlias()) ->select('COUNT('.$this->getTableAlias().'.id)') ->where($this->getTableAlias().'.name = :name') ->setParameter('name', $name); if (null !== $ignoreId) { $qb->andWhere($this->getTableAlias().'.id != :id') ->setParameter('id', $ignoreId); } return (int) $qb->getQuery()->getSingleScalarResult() > 0; } /** * The list's search box matches the name and the description. * * @return array */ protected function addCatchAllWhereClause($q, $filter): array { return $this->addStandardCatchAllWhereClause($q, $filter, [ $this->getTableAlias().'.name', $this->getTableAlias().'.description', ]); } /** * @return array */ protected function getDefaultOrder(): array { return [ [$this->getTableAlias().'.name', 'ASC'], ]; } }