0
我知道人們問了很多次,但我真的不知道如何解決它。Symfony2.8:spl_object_hash()期望參數1是對象,給出的整數
我認爲錯誤是在控制器內的方法某處:
/**
* View action.
*
* @param Website $website Website entity
* @param Request $request
* @param \Symfony\Component\HttpFoundation\Request $request HTTP Request
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response HTTP Response
* @internal param Rating $rating
* @Route(
* "/{id}",
* name="website_view",
*)
* @Method({"GET", "POST"})
*/
public function viewAction(Website $website, Request $request)
{
$websiteId = $this->get('app.repository.website')->findOneById($website)->getId();
$rating = new Rating();
$form = $this->createForm(RatingType::class, $rating);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$rating->setWebsite($websiteId);
$this->get('app.repository.rating')->save($rating, $website);
$this->addFlash('success', 'message.created_successfully');
}
return $this->render(
'website/view.html.twig',
['website' => $website,
'rating' => $rating,
'form' => $form->createView()]
);
問題的行是:
它的網站ID未設置爲評級如果線路失蹤,但當線添加我得到以上錯誤。
我在Rating實體中有必要的getter和setter,並且在評估存儲庫中使用persist和flush保存方法。
難道問題是我已經將此方法放在網站控制器中而不是評級控制器中?
在此先感謝您的幫助。
謝謝:)那麼簡單的解決方案,我沒有拿出與... – shiki