简体   繁体   English

可捕获的致命错误:传递给Symfony :: render()的参数3必须是Symfony \\ .. \\ Response的实例,给定数组

[英]Catchable Fatal Error: Argument 3 passed to Symfony::render() must be an instance of Symfony\..\Response, array given

I want to pass 2 arrays into render function in controller. 我想将2个数组传递给控制器​​中的render函数。

How do I do that? 我怎么做?

For now I have something like that: 现在我有这样的事情:

class GradebookController extends Controller
{
    /**
     * @Route("/gradebook", name="_gradebook")
     */
    public function indexAction()
    {

       if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
           return $this->redirect($this->generateUrl('_login'));
       }

       $em = $this->getDoctrine()->getManager();

       $subject = $em->getRepository('AppBundle:Subject')->findAll();

       $students = $em->getRepository('AppBundle:User')->findBy(
           array('roles'=>'a:0:{}')
       );

       return $this->render('::gradebook.html.twig', array('students'=>$students),
                                                     array('subjects'=>$subject));
    }
}

将两者组合成具有多个键的数组。

return $this->render('::gradebook.html.twig', array('students' => $students, 'subjects' => $subject));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Symfony 2嵌入式表单:可捕获的致命错误:传递给Entity的参数1 :: addProperty必须是XX \\ MyClass的一个实例,给出的数组 - Symfony 2 Embedded Forms: Catchable Fatal Error: Argument 1 passed to Entity::addProperty must be an instance of XX\MyClass, array given 主义(Symfony3)可捕获的致命错误:传递给(bundle)的参数1必须是(bundle)的实例,给定数组 - Doctrine (Symfony3) Catchable Fatal Error: Argument 1 passed to (bundle) must be an instance of (bundle), array given 可捕获的致命错误:传递给...的参数1必须是...,给定数组的实例 - Catchable Fatal Error: Argument 1 passed to … must be an instance of …, array given 可捕获的致命错误:传递给Doctrine \\ DBAL \\ Connection :: update()的参数3必须为数组类型,在symfony2 update中没有给出 - Catchable Fatal Error: Argument 3 passed to Doctrine\DBAL\Connection::update() must be of the type array, none given in symfony2 update Action Symfony2:ContextErrorException:可捕获的致命错误:传递给[…] :: __ construct()的参数1必须实现接口[…]没有给出 - Symfony2: ContextErrorException: Catchable Fatal Error: Argument 1 passed to […]::__construct() must implement interface […] none given 可捕获的致命错误:传递给\\ Entity \\ Image :: setFile()的参数1必须是Symfony \\ Component \\ HttpFoundation \\ File \\ UploadedFile的实例, - Catchable Fatal Error: Argument 1 passed to \Entity\Image::setFile() must be an instance of Symfony\Component\HttpFoundation\File\UploadedFile, Symfony 2可捕获的致命错误:传递给Sg \\ DatatablesBundle \\ Datatable \\ :: __ construct()的参数1必须是的实例 - Symfony 2 Catchable Fatal Error: Argument 1 passed to Sg\DatatablesBundle\Datatable\::__construct() must be an instance of Symfony2可捕获的致命错误:参数1传递给实体可捕获的致命错误:参数1传递给实体 - Symfony2 Catchable Fatal Error: Argument 1 passed to entity Catchable Fatal Error: Argument 1 passed to entity PHP - 可捕获的致命错误:传递给Too的参数1必须是Foo的实例,Boo的实例给出了吗? - PHP - Catchable fatal error: Argument 1 passed to Too must be an instance of Foo, instance of Boo given? Symfony服务容器-可捕获的致命错误-传递给构造的参数 - Symfony service container - Catchable Fatal Error - Argument passed to construct
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM