Files
mautic-marketing-program-bu…/Entity/TaskRepository.php
T
Alexandre Gain 71ff11390b refactor(plugin): rename Plan to Program and add audience/UTM routes
Rename the Plan bundle to Program across config, routes, menus, and
controllers (Plan -> Initiative), bump version to 0.16.0, and introduce
new audience and UTM taxonomy routes and permissions to support the
expanded Programs feature set.
2026-11-13 22:01:32 +01:00

86 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
namespace MauticPlugin\ProgramBundle\Entity;
use Mautic\CoreBundle\Entity\CommonRepository;
/**
* @extends CommonRepository<Task>
*/
class TaskRepository extends CommonRepository
{
use CountsItemsByTypeTrait;
public function getTableAlias(): string
{
return 't';
}
/**
* Loads the initiative, the dependencies (with their depends-on task) and the RACI rows (with their
* stakeholders) with the tasks, 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, 'init', 'dep', 'depTask', 'raci', 'raciStakeholder')
->leftJoin($alias.'.initiative', 'init')
->leftJoin($alias.'.dependencies', 'dep')
->leftJoin('dep.dependsOn', 'depTask')
->leftJoin($alias.'.raci', 'raci')
->leftJoin('raci.stakeholders', 'raciStakeholder');
return parent::getEntities($args);
}
/**
* All tasks of an initiative, ordered by name, with their dependencies and RACI rows loaded.
*
* @return Task[]
*/
public function findByInitiative(Initiative $initiative): array
{
return $this->createQueryBuilder('t')
->select('t', 'dep', 'depTask', 'raci', 'raciStakeholder')
->leftJoin('t.dependencies', 'dep')
->leftJoin('dep.dependsOn', 'depTask')
->leftJoin('t.raci', 'raci')
->leftJoin('raci.stakeholders', 'raciStakeholder')
->where('t.initiative = :initiative')
->setParameter('initiative', $initiative)
->orderBy('t.name', 'ASC')
->addOrderBy('t.id', 'ASC')
->getQuery()
->getResult();
}
/**
* 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'],
];
}
}