When a task transitions to a final status, archives the current task and creates a new occurrence with recalculated dates. Adds TaskStatusRepository::findFirstNonFinal() to assign the initial status to the new task. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
735 B
PHP
30 lines
735 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\TaskStatus;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
class TaskStatusRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, TaskStatus::class);
|
|
}
|
|
|
|
public function findFirstNonFinal(): ?TaskStatus
|
|
{
|
|
return $this->createQueryBuilder('s')
|
|
->where('s.isFinal = :final')
|
|
->setParameter('final', false)
|
|
->orderBy('s.position', 'ASC')
|
|
->setMaxResults(1)
|
|
->getQuery()
|
|
->getOneOrNullResult()
|
|
;
|
|
}
|
|
}
|