first delivery
This commit is contained in:
1 parent
793fbc0c91
commit
f6684f3b2e
65 files changed
+5828
No files matched your search
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\PlanBundle\Entity;
|
||||
|
||||
use Mautic\CoreBundle\Entity\CommonRepository;
|
||||
|
||||
/**
|
||||
* @extends CommonRepository<Task>
|
||||
*/
|
||||
class TaskRepository extends CommonRepository
|
||||
{
|
||||
public function getTableAlias(): string
|
||||
{
|
||||
return 't';
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the plan and the parent 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, 'pl', 'pa')
|
||||
->leftJoin($alias.'.plan', 'pl')
|
||||
->leftJoin($alias.'.parent', 'pa');
|
||||
|
||||
return parent::getEntities($args);
|
||||
}
|
||||
|
||||
/**
|
||||
* All tasks of a plan, ordered by name.
|
||||
*
|
||||
* @return Task[]
|
||||
*/
|
||||
public function findByPlan(Plan $plan): array
|
||||
{
|
||||
return $this->createQueryBuilder('t')
|
||||
->where('t.plan = :plan')
|
||||
->setParameter('plan', $plan)
|
||||
->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'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user