|
|
@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\HeaderUtils; |
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
use Symfony\Component\HttpFoundation\StreamedResponse; |
|
|
|
use Symfony\Component\Routing\Attribute\Route; |
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
|
|
|
use Symfony\Component\Workflow\WorkflowInterface; |
|
|
@ -409,6 +410,55 @@ class TaskController extends AbstractController |
|
|
|
return $response; |
|
|
|
} |
|
|
|
|
|
|
|
#[Route('/download/{slug}.csv', name: 'app_task_csv')]
|
|
|
|
public function csv(Request $request, EntityManagerInterface $entityManager, $slug): Response |
|
|
|
{ |
|
|
|
$repository = $entityManager->getRepository(Project::class); |
|
|
|
$project = $repository->findOneBySlug($slug); |
|
|
|
|
|
|
|
if (!$project) { |
|
|
|
$this->addFlash('warning', 'Projet non trouvé !'); |
|
|
|
return $this->redirect($request->headers->get('referer')); |
|
|
|
} |
|
|
|
|
|
|
|
$response = new StreamedResponse(); |
|
|
|
|
|
|
|
$response->setCallback(function () use ($project): void { |
|
|
|
$output = fopen('php://output', 'a'); |
|
|
|
fputcsv( |
|
|
|
$output, [ |
|
|
|
'name', |
|
|
|
'description', |
|
|
|
'osm', |
|
|
|
'geojson', |
|
|
|
'status', |
|
|
|
] |
|
|
|
); |
|
|
|
foreach($project->getTasks() as $task) { |
|
|
|
fputcsv( |
|
|
|
$output, |
|
|
|
[ |
|
|
|
$task->getName(), |
|
|
|
$task->getDescription(), |
|
|
|
$task->getOsm(), |
|
|
|
$task->getGeojson(), |
|
|
|
$task->getStatus(), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
fclose($output); |
|
|
|
flush(); |
|
|
|
}); |
|
|
|
|
|
|
|
$response->headers->set('Content-Type', 'text/csv'); |
|
|
|
$response->headers->set('Content-Disposition', HeaderUtils::makeDisposition( |
|
|
|
HeaderUtils::DISPOSITION_ATTACHMENT, |
|
|
|
sprintf('%s.csv', $project->getSlug()) |
|
|
|
)); |
|
|
|
|
|
|
|
return $response; |
|
|
|
} |
|
|
|
|
|
|
|
#[Route('/{slug}/changesets', name: 'app_task_changesets')]
|
|
|
|
public function changesets(OpenStreetMapClient $osmClient, EntityManagerInterface $entityManager, $slug): Response |
|
|
|
{ |
|
|
|