- Correct getChoices() docblock to reflect translated label => enum backing value order instead of value => label - Re-indent Smart Links menu config to match actual array nesting - Align assignment operators in RefreshStatsCommand - Add missing newline at end of RefreshStatsCommand.php
64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Entity;
|
|
|
|
use Mautic\CoreBundle\Entity\CommonRepository;
|
|
|
|
/**
|
|
* @extends CommonRepository<UtmTaxonomy>
|
|
*/
|
|
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<int, mixed>
|
|
*/
|
|
protected function addCatchAllWhereClause($q, $filter): array
|
|
{
|
|
return $this->addStandardCatchAllWhereClause($q, $filter, [
|
|
$this->getTableAlias().'.name',
|
|
$this->getTableAlias().'.description',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return array<array{0: string, 1: string}>
|
|
*/
|
|
protected function getDefaultOrder(): array
|
|
{
|
|
return [
|
|
[$this->getTableAlias().'.name', 'ASC'],
|
|
];
|
|
}
|
|
}
|