首页 > 解决方案 > I can not retrieve the parameters of a URL passed in GET in symfony 3

问题描述

I try to retrieve certain parameters of a url that I passed in GET, in my links, but It doesn't work.

That's the part of my twig file where I pass the parameters in a linkters:

 <a href="{{ path('patient_booking_confirmation') }}?idMedecin={{ medecin.id }}?date={{ date }}?heure={{ time }}" class="boutonBookingPage" id="confirmationPaiement">Confirmer votre Rendez-Vous</a>

Note that in this twig I have the values ​​of these parameters, and I would like to have these same values ​​on the twig on which the link returns to me.

And here is the controller:

   public function patientHandleBookingAction(Request $request){

      $id = $request->query->get('id');
     $date = $request->query->get('date');
     $time = $request->query->get('time');
    // $user = $this->getUser();

    $em = $this->getDoctrine()->getManager();
    $repoPatient = $em->getRepository('DoctixPatientBundle:Patient');
    $patient = $repoPatient->findOneBy(array(
        'user' => $this->getUser()
    ));

    $repoMedecin = $em->getRepository('DoctixMedecinBundle:Medecin');
    $medecin = $repoMedecin->findOneBy(array(
        'id' => $request->query->get("idMedecin")));


    $mailer = $this->get('mailer');
    $message = (new \Swift_Message('Email de Confirmaton'))
        ->setFrom("medmamtest@gmail.com")
        ->setTo($patient->getUser()->getUsername())
        ->setBody(
            $this->renderView(
                // app/Resources/views/Emails/registration.html.twig
                'Emails/registration.html.twig',
                array('name' => 'mam')
            ),
            'text/html'
        );

    $mailer->send($message);
    if($mailer){

      $booking = new Booking();
      $booking->setMedecin($medecin);
      $booking->setPatient($patient);
      $booking->setDateRdv($date);
      $booking->setHeureRdv($time);
      $booking->setValiderRdv(0);


    }

    $em->persist($booking);
    $em->flush();

    // A remplacer par un contenu plus approprié
    return $this->render('DoctixPatientBundle:Patient:confirm.html.twig',array(
            'time' => $request->query->get("time"),
            'date' => $request->query->get("date"),
            'medecin' => $medecin,
            'patient' => $patient,
           // 'date' => $date,
           // 'time' => $time
));

}

And in this controller I manage to recover the values ​​of the parameters doctor and patient, but not the date and time, and it is the date and the time that I want to recover in addition to doctor and patient, to be able to save after sending the mail.

And here is my twig file where I use the values ​​of the parameters :

 <div class="box_general_2 add_bottom_45">
                            <div class="main_title_4">
                                <h3><i class="icon_circle-slelected"></i> {{ date }} {{ time }} </h3>
                            </div>
                            <div class="col-xl-9 col-lg-8">
                                <div class="strip_list wow fadeIn">

                                    <figure>
                                        <a href="#"><img src="{{ vich_uploader_asset(medecin.media, 'imageFile') }}"
                                                         alt="{{ medecin.media.imagename }}"> </a>
                                    </figure>
                                    <p>
                                        <small>{{ medecin.specialite.nom }}</small>
                                    <h3>Dr. {{ medecin.user.prenom|capitalize }} {{ medecin.user.nom|upper }} </h3>
                                    </p>

                                </div>
                                <div class="indent_title_in">

                                    <i class="pe-7s-user"></i>
                                    <h3>Patient</h3>
                                    <p>{{ patient.user.prenom|capitalize }} {{ patient.user.nom|upper }}</p>
                                </div>

                                <div class="indent_title_in">
                                    <i class="pe-7s-cash"></i>
                                    <h3>Moyens de Paiements</h3>
                                    <p>Le paiement s'effectue via Orange Money, soit sur notre platefome ou via
                                        directement
                                        votre mobile.</p>
                                </div>

                                <div class="indent_title_in">
                                    <i class="pe-7s-cash"></i>
                                    <h3>Tarif et Remboursement</h3>
                                    <p>Le remboursement est possible que lorsque le médecin n'honore pas son
                                        rendez-vous,
                                        ainsi vous serez remboursé dans les minutes qui suivent. Merci.</p>
                                </div>

                            </div>

And in the display I do not get the date and time

Thanks

标签: symfonyurlget

解决方案


'&' 是多个 url 参数之间的分隔符('?' 仅用于启动 url 的获取参数部分)。即尝试:

<a href="{{ path('patient_booking_confirmation') }}?idMedecin={{ medecin.id }}&date={{ date }}&heure={{ time }}" class="boutonBookingPage" id="confirmationPaiement">Confirmer votre Rendez-Vous</a>

推荐阅读