Symfony2: Warning: spl_object_hash() expects parameter 1 to be object, integer given

余生颓废 提交于 2019-12-03 15:48:01

Its looking for you to use an object with an instance of Course just passing the ID of the course does not work.

You could do:

//...
$course = $this->getDoctrine()
               ->getManager()
               ->getRepository('Namespace:Course')
               ->findOneById(5);
$project->setCourse($course);
//...

As Full mentions if you know that the entity already exists you can just set it without a db lookup by doing:

$project->setCourse($this->getDoctrine()
                         ->getManager()
                         ->getReference('Namespace:Course', 5)
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!