2016-03-07 11 views
0

我給了以下錯誤:錯誤與實體的多個參數,可以Symfony2的

Catchable Fatal Error: Argument 1 passed to BackendBundle\Entity\Notification::sendSystemMessage() 
must be an instance of BackendBundle\Entity\BackendBundle\Entity\User, instance of 
Proxies\__CG__\BackendBundle\Entity\User given 

我在Notification.php類中的方法是:

/** 
    * Send System message, to be used after creating a blank one 
    * 
    * @param \BackendBundle\Entity\User $reciever 
    * 
    * @param string $message 
    * 
    * @return Notification 
    */ 
    public function sendSystemMessage(BackendBundle\Entity\User $reciever, $message) 
    { 
     $this->setReciever($reciever); 
     $this->setMessage($message); 
     $this->setTimestamp(new \DateTime()); 
     $this->setReaded(false); 
     $this->setSystemMessage(true); 

     return $this; 
    } 

當我使用的setter和獲得者喜歡setReciever,它完美的作品,但是當我嘗試調用多個參數時,我得到了這個錯誤,我是我犯了一個錯誤,或者在實體類中不能有多個參數方法?

+0

該錯誤消息來自碼別的地方,您可以在其中調用sendSystemMessage()函數。您的$ reciever參數的類型錯誤。 – purpleninja

+0

這是我的第一個想法,但我打電話setReciever方法具有相同的驗證,它效果很好 – ericksho

+0

你是什麼意思?你可以顯示代碼,你在哪裏比較兩個發送相同的參數,還有setReciever的函數描述? – purpleninja

回答

0

Credits to Cerad。

我的問題是,我有

public function sendSystemMessage(BackendBundle\Entity\User $reciever, $message) 

,當我需要

public function sendSystemMessage(\BackendBundle\Entity\User $reciever, $message) 

反斜槓,總算有了一個不同的路徑User類