*/ class TaskRepository extends CommonRepository { use CountsItemsByTypeTrait; public function getTableAlias(): string { return 't'; } /** * Loads the program, 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 $args */ public function getEntities(array $args = []) { $alias = $this->getTableAlias(); $args['qb'] = $this->createQueryBuilder($alias) ->select($alias, 'init', 'dep', 'depTask', 'raci', 'raciStakeholder') ->leftJoin($alias.'.program', '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 program, ordered by name, with their dependencies and RACI rows loaded. * * @return Task[] */ public function findByProgram(Program $program): 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.program = :program') ->setParameter('program', $program) ->orderBy('t.name', 'ASC') ->addOrderBy('t.id', 'ASC') ->getQuery() ->getResult(); } /** * 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'], ]; } }