$mapping */ public function __invoke(int $projectId, int $workflowId, array $mapping): string { if (!$this->security->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException('Access denied: ROLE_ADMIN required.'); } $project = $this->entityManager->find(Project::class, $projectId); if (!$project) { return json_encode(['error' => 'Project not found.']); } $fakeRequest = Request::create('', 'POST', [], [], [], [], json_encode([ 'workflowId' => $workflowId, 'mapping' => $mapping, ])); try { $result = $this->processor->process( $project, operation: new Post(name: 'switch_workflow'), uriVariables: ['id' => $projectId], context: ['request' => $fakeRequest], ); } catch (Throwable $e) { return json_encode(['error' => $e->getMessage()]); } return json_encode([ 'migratedTaskCount' => $result->migratedTaskCount, 'projectId' => $result->projectId, 'workflowId' => $result->workflowId, ]); } }