feat : add TaskCalendarProcessor for CalDAV sync after DB operations
Handles Patch (persist + sync + recurrence check) and Delete (remove + cleanup Zimbra events). Updates TaskNumberProcessor to sync newly created tasks to calendar. Wires TaskCalendarProcessor as processor for Patch/Delete on Task entity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Post;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use App\Entity\Task;
|
||||
use App\Repository\TaskRepository;
|
||||
use App\Service\CalDavService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
|
||||
@@ -25,6 +26,7 @@ final readonly class TaskNumberProcessor implements ProcessorInterface
|
||||
private ProcessorInterface $persistProcessor,
|
||||
private TaskRepository $taskRepository,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private CalDavService $calDavService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -33,12 +35,17 @@ final readonly class TaskNumberProcessor implements ProcessorInterface
|
||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): mixed
|
||||
{
|
||||
if ($operation instanceof Post && null !== $data->getProject()) {
|
||||
return $this->entityManager->wrapInTransaction(function () use ($data, $operation, $uriVariables, $context) {
|
||||
$result = $this->entityManager->wrapInTransaction(function () use ($data, $operation, $uriVariables, $context) {
|
||||
$maxNumber = $this->taskRepository->findMaxNumberByProjectForUpdate($data->getProject());
|
||||
$data->setNumber($maxNumber + 1);
|
||||
|
||||
return $this->persistProcessor->process($data, $operation, $uriVariables, $context);
|
||||
});
|
||||
|
||||
$this->calDavService->syncTask($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $this->persistProcessor->process($data, $operation, $uriVariables, $context);
|
||||
|
||||
Reference in New Issue
Block a user