0

我给出了以下错误:

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;
    }

当我使用 setReciever 之类的 setter 和 getter 时,它工作得很好,但是当我尝试调用多个参数时,我得到了这个错误,我犯了一个错误,或者实体类中不能有多个参数方法?

4

1 回答 1

0

归功于 Cerad。

我的问题是我有

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

当我需要的时候

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

该反斜杠让我为 User 类提供了不同的路径

于 2016-03-07T17:25:53.847 回答