Bonjour,

J'ai un problème avec mes url sur mon site, un petit bug qui est assez dérangeant.
Mes url sont de cette forme : http://localhost:8000/organization/my-organization-test/37
Ce qui fonctionne très bien.

Le bug que j'ai est que je peux remplacer "my-organization-test" par n'importe quoi, tant que l'ID existe, la page s'affiche quand même.
Lorsque je fais http://localhost:8000/organization/my-xxxx-test/37, l'organisation avec l'ID 37 s'affiche..

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
public function standardPageAction(Organizations $organization, $id)
    {
        $arraypicture = array();
        $firstPicture = $this->getDoctrine()->getRepository('AppBundle:Organizations')->getFirstPicture($id);
        if (null !== $firstPicture->getFirstPicture()) {
            array_push($arraypicture, 'uploads/first_image/'.$firstPicture->getFirstPicture());
        } elseif (null !== $organization->getOrgaStructure()) {
            if (null !== $organization->getOrgaStructure()->getType()) {
                if (null !== $organization->getOrgaStructure()->getType()->getPicture()) {
                    array_push($arraypicture, 'uploads/etablissement/'.$organization->getOrgaStructure()->getType()->getPicture());
                } else {
                    array_push($arraypicture, 'images/Etablissement.jpeg');
                }
            } else {
                array_push($arraypicture, 'images/Etablissement.jpeg');
            }
        } else {
            array_push($arraypicture, 'images/Etablissement.jpeg');
        }
 
        $picture = $this->getDoctrine()->getRepository('AppBundle:Media')->getImageByOrganizations($id);
 
        foreach ($picture as $pictures) {
            array_push($arraypicture, 'uploads/image/'.$pictures->getFileName());
        }
 
        $user = $this->getUser();
        $emuser = $this->getDoctrine()->getRepository('ApplicationSonataUserBundle:User');
        $usero = $emuser->getOrganizationsByUser($id);
 
        $comment = new Comment();
        $comment->setOrganizationsComment($organization);
        $form = $this->createForm('AppBundle\Form\Type\CommentType', $comment);
 
        $formHandler = new Handler\CommentHandler($form, $this->get('request'), $this->get('doctrine.orm.default_entity_manager'));
 
        if ($formHandler->process()) {
            return $this->redirectToRoute('structure_page', array('id' => $organization->getId(), 'name' => $organization->getName()));
        }
 
        $alertContent = new AlertContent();
        $alertForm = $this->createForm('AppBundle\Form\Type\AlertContentType', $alertContent);
 
        $comments = $organization->getComments();
        $this->addFlash(
            '_target_path',
            $this->generateUrl('structure_page', array('id' => $organization->getId(), 'name' => $organization->getName()))
        );
        return $this->render(':front:organizationPage.html.twig', array(
            'form' => $form->createView(),
            'pictures' => $arraypicture,
            'user' => $user,
            'usero' => $usero,
            'alertForm' => $alertForm->createView(),
            'organization' => $organization,
            'comments' => $comments,
        ));
    }
Ce à quoi je pensai pour régler cela, c'était de comparer le nom de mon organisation que je peux récupérer par exemple en faisant ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
$name = $firstPicture->getName($id);
Et le nom de l'organisation dans mon url. Malheureusement je ne sais pas comment récupérer ce nom en question dans l'url pour la comparaison.

la logique que à laquelle j'ai pensé était comme suis : si "nom de l'organisation" est différent du "nom dans url",alors ca me retourne une page 404.

Avez vous une piste ou une idée qui pourrait m'aider s'il vous plaît ?

Je vous remercie d'avance pour vos réponses et je vous répondrai au plus tôt