Files
mautic-marketing-program-bu…/Entity/PlanRepository.php
T
2026-11-07 19:31:49 +01:00

58 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace MauticPlugin\PlanBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<Plan>
*/
class PlanRepository extends CommonRepository
{
public function getTableAlias(): string
{
return 'p';
}
/**
* Loads the owner and category with the plans, so that the list doesn't query them one by one.
*
* @param array<string, mixed> $args
*/
public function getEntities(array $args = [])
{
$alias = $this->getTableAlias();
$args['qb'] = $this->createQueryBuilder($alias)
->select($alias, 'o', 'c')
->leftJoin($alias.'.owner', 'o')
->leftJoin($alias.'.category', 'c');
return parent::getEntities($args);
}
/**
* The list's search box matches the name.
*
* @return array<int, mixed>
*/
protected function addCatchAllWhereClause($q, $filter): array
{
return $this->addStandardCatchAllWhereClause($q, $filter, [
$this->getTableAlias().'.name',
]);
}
/**
* @return array<array{0: string, 1: string}>
*/
protected function getDefaultOrder(): array
{
return [
[$this->getTableAlias().'.name', 'ASC'],
];
}
}