Release 2.18 (#4878)
This commit is contained in:
@@ -19,15 +19,10 @@ use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
/**
|
||||
* @extends \Doctrine\ORM\EntityRepository<Tag>
|
||||
* @extends EntityRepository<Tag>
|
||||
*/
|
||||
class TagRepository extends EntityRepository
|
||||
{
|
||||
/**
|
||||
* See KimaiFormSelect.js (maxOptions) as well.
|
||||
*/
|
||||
public const MAX_AMOUNT_SELECT = 500;
|
||||
|
||||
public function saveTag(Tag $tag): void
|
||||
{
|
||||
$entityManager = $this->getEntityManager();
|
||||
@@ -64,18 +59,11 @@ class TagRepository extends EntityRepository
|
||||
return $this->findOneBy(['name' => $tagName, 'visible' => $visible]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all visible tag names in alphabetical order.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function findAllTagNames(?string $filter = null): array
|
||||
private function findAllTagsQuery(?string $filter = null): QueryBuilder
|
||||
{
|
||||
$qb = $this->createQueryBuilder('t');
|
||||
|
||||
$qb
|
||||
->select('t.name')
|
||||
->addOrderBy('t.name', 'ASC');
|
||||
$qb->addOrderBy('t.name', 'ASC');
|
||||
|
||||
$qb->andWhere($qb->expr()->eq('t.visible', ':visible'));
|
||||
$qb->setParameter('visible', true, ParameterType::BOOLEAN);
|
||||
@@ -85,7 +73,27 @@ class TagRepository extends EntityRepository
|
||||
$qb->setParameter('filter', '%' . $filter . '%');
|
||||
}
|
||||
|
||||
return array_column($qb->getQuery()->getScalarResult(), 'name');
|
||||
return $qb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all visible tag names in alphabetical order.
|
||||
*
|
||||
* @return array<Tag>
|
||||
*/
|
||||
public function findAllTags(?string $filter = null): array
|
||||
{
|
||||
return $this->findAllTagsQuery($filter)->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all visible tag names in alphabetical order.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public function findAllTagNames(?string $filter = null): array
|
||||
{
|
||||
return array_column($this->findAllTagsQuery($filter)->select('t.name')->getQuery()->getScalarResult(), 'name');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user