@ -8,7 +8,6 @@ use App\Entity\Task;
use App\Form\CommentType ;
use App\Form\TaskType ;
use App\Service\GeoJsonManager ;
use App\Service\OpenStreetMapClient ;
use Doctrine\ORM\EntityManagerInterface ;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController ;
use Symfony\Component\Form\Extension\Core\Type\SubmitType ;
@ -24,12 +23,13 @@ use Symfony\Component\Workflow\WorkflowInterface;
#[Route('/task')]
class TaskController extends AbstractController
{
// Page de créatiom d’une tâche
// Page de créatiom d’une tâche
#[Route('/create', name: 'app_task_create')]
public function create ( Request $request , EntityManagerInterface $entityManager ) : Response
{
if ( ! $request -> query -> has ( 'slug' )) {
$this -> addFlash ( 'warning' , 'Projet non spécifié !' );
$this -> addFlash ( 'warning' , 'Projet non spécifié !' );
return $this -> redirectToRoute ( 'app_project' );
}
@ -39,7 +39,8 @@ class TaskController extends AbstractController
$project = $repository -> findOneBySlug ( $slug );
if ( ! $project ) {
$this -> addFlash ( 'warning' , 'Projet non trouvé !' );
$this -> addFlash ( 'warning' , 'Projet non trouvé !' );
return $this -> redirectToRoute ( 'app_project' );
}
@ -70,13 +71,12 @@ class TaskController extends AbstractController
}
}
return $this -> render ( 'task/create.html.twig' , [
'project' => $project ,
'create_form' => $createForm ,
]);
}
// Page spécifique à une tâche, où l’on trouve tout ce qui la concerne
#[Route('/{slug}', name: 'app_task_show')]
public function show ( Request $request , EntityManagerInterface $entityManager , GeoJsonManager $geoJsonManager , $slug ) : Response
@ -90,6 +90,7 @@ class TaskController extends AbstractController
if ( ! $request -> headers -> has ( 'Referer' )) {
throw $this -> createNotFoundException ( 'Task not found' );
}
return $this -> redirect ( $request -> headers -> get ( 'Referer' ));
}
@ -135,8 +136,8 @@ class TaskController extends AbstractController
'left' => $bbox [ 'minx' ],
'right' => $bbox [ 'maxx' ],
'changeset_comment' => sprintf ( '%s %s' , $project -> getName (), $task -> getName ()),
'changeset_source' => $project -> getSource (),
'changeset_hashtags' => $project -> getHashtags (),
'changeset_source' => $project -> getSource (),
'changeset_hashtags' => $project -> getHashtags (),
];
}
@ -177,9 +178,8 @@ class TaskController extends AbstractController
try {
$entityManager -> persist ( $comment );
$entityManager -> flush ();
} catch ( \Exception $exception ) {
$this -> addFlash ( 'danger' , 'Impossible de commenter ! ' . $exception -> getMessage ());
$this -> addFlash ( 'danger' , 'Impossible de commenter ! ' . $exception -> getMessage ());
}
}
@ -234,13 +234,13 @@ class TaskController extends AbstractController
if ( ! $task ) {
$this -> addFlash ( 'warning' , 'Tâche non trouvée !' );
return $this -> redirect ( $request -> headers -> get ( 'Referer' ));
}
$project = $task -> getProject ();
try {
$entityManager -> remove ( $task );
$entityManager -> flush ();
@ -260,6 +260,7 @@ class TaskController extends AbstractController
if ( ! $task ) {
$this -> addFlash ( 'warning' , 'Tâche non trouvée !' );
return $this -> redirectToRoute ( 'app_project' );
}
@ -317,6 +318,7 @@ class TaskController extends AbstractController
if ( ! $request -> headers -> has ( 'Referer' )) {
throw $this -> createNotFoundException ( 'Task not found' );
}
return $this -> redirect ( $request -> headers -> get ( 'Referer' ));
}
@ -346,6 +348,7 @@ class TaskController extends AbstractController
if ( ! $request -> headers -> has ( 'Referer' )) {
throw $this -> createNotFoundException ( 'Task not found' );
}
return $this -> redirect ( $request -> headers -> get ( 'Referer' ));
}
@ -383,6 +386,7 @@ class TaskController extends AbstractController
'warning' ,
'Tâche non trouvée !'
);
return $this -> redirect ( $request -> headers -> get ( 'referer' ));
}
@ -401,7 +405,7 @@ class TaskController extends AbstractController
return $response ;
}
// Renvoie la liste des tâches du projet sous forme de CSV (ce qui devrait
// corresponddre à ce que l’on a pu importer)
#[Route('/download/{slug}.csv', name: 'app_task_csv')]
@ -412,6 +416,7 @@ class TaskController extends AbstractController
if ( ! $project ) {
$this -> addFlash ( 'warning' , 'Projet non trouvé !' );
return $this -> redirect ( $request -> headers -> get ( 'referer' ));
}
@ -428,9 +433,9 @@ class TaskController extends AbstractController
'status' ,
]
);
foreach ( $project -> getTasks () as $task ) {
foreach ( $project -> getTasks () as $task ) {
fputcsv (
$output ,
$output ,
[
$task -> getName (),
$task -> getDescription (),
@ -452,5 +457,4 @@ class TaskController extends AbstractController
return $response ;
}
}