Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php @ParamConverter注释未找到Symfony 5 get fail对象_Php_Symfony - Fatal编程技术网

Php @ParamConverter注释未找到Symfony 5 get fail对象

Php @ParamConverter注释未找到Symfony 5 get fail对象,php,symfony,Php,Symfony,我有一个在我的事件中添加用户的表单,但是当我添加用户时,我尝试在这个事件中添加一个角色,但是当执行第二个函数时,我失败了 @ParamConverter注释找不到App\Entity\Evento对象。 我看不出有什么问题,谢谢 public function registro(Request $request, UserPasswordEncoderInterface $encoder, Evento $evento) { $evento = $this->get

我有一个在我的事件中添加用户的表单,但是当我添加用户时,我尝试在这个事件中添加一个角色,但是当执行第二个函数时,我失败了

@ParamConverter注释找不到App\Entity\Evento对象。

我看不出有什么问题,谢谢

public function registro(Request $request, UserPasswordEncoderInterface $encoder, Evento $evento)
    {
        $evento = $this->getDoctrine()->getRepository(Evento::class)->findOneById($evento);
        $user = new user();
        $form = $this->createForm(RegisterUsuarioEventoType::class, $user);
        //rellenar el objeto con los datos del formulario
        $form->handleRequest($request);
        //comprobando si el formulario se ha enviado
        if($form->isSubmitted() && $form->isValid()){
            //modificando objeto para guardarlo
            $user->setRole('ROLE_USER');
            $user->setFecha(new \DateTime('now'));
            $encoded = $encoder->encodePassword($user, $user->getPassword());
            $user->setPassword($encoded);
            $user->addEvento($evento); 
            $evento->addUser($user);
            $em = $this->getDoctrine()->getManager();
            $em->persist($user);
            $em->flush();
            return $this->redirect($this->generateUrl('registro2', ['id' => $user->getId()]));
        }
        return $this->render('evento/register-evento.html.twig', [
            'form' => $form->createView()
        ]);
    }
我的第二个函数在第一个函数刷新数据库时执行

    public function registro2(Request $request, Evento $evento)
    {
        $userhasevento = new UserHasEvento();
        $form = $this->createForm(RegisterUsuarioEvento2Type::class, $userhasevento);
        $form->handleRequest($request);        
        if($form->isSubmitted() && $form->isValid()){
            $contactFormData = $form->getData();

            $userhasevento->SetTipoinvitado($contactFormData['tipo'],'text/plain');
            $userhasevento->SetFechainscripcion(new \DateTime('now'));
            $userhasevento->SetEventoid($evento->getId());
            $userhasevento->SetUserid($user->getId());

            $em = $this->getDoctrine()->getManager();
            $em->persist($userhasevento);
            $em->flush();
            
            return $this->redirect($this->generateUrl('detalle', ['id' => $evento->getId()]));
 
        }        

        return $this->render('evento/AsignarEvento.html.twig', array(
            'UserHasEvento' => $userhasevento,
            'form' => $form->createView()
        ));
}
路线:


registro:
    path: /registroEvento/{id}
    controller: App\Controller\EventoController::registro    

registro2:
    path: /registroEvento/tipo-invitado/{id}
    controller: App\Controller\EventoController::registro2    
内部注册表

return $this->redirect($this->generateUrl('registro2', ['id' => $user->getId()]));
应改为

return $this->redirect($this->generateUrl('registro2', ['id' => $evento->getId()]));
或者你应该改变

public function registro2(Request $request, Evento $evento)

内部注册表

return $this->redirect($this->generateUrl('registro2', ['id' => $user->getId()]));
应改为

return $this->redirect($this->generateUrl('registro2', ['id' => $evento->getId()]));
或者你应该改变

public function registro2(Request $request, Evento $evento)


请提供路线声明。我添加路线,谢谢请提供路线声明。我添加路线,谢谢谢谢我没有看到失败:['id'=>$evento->getId()]);谢谢谢谢,我没有看到失败:['id'=>$evento->getId()]);谢谢