0

我创建了扩展 FOSOAuthServerBundle 的客户端。这个客户端的代码如下:

<?php 
namespace Acme\ApiBundle\Entity;
use FOS\OAuthServerBundle\Entity\Client as BaseClient;
use Doctrine\ORM\Mapping as ORM;
 /**
 * Class Client
 *
 * @package Acme\ApiBundle\Entity
 *
 * @ORM\Table("oauth2_clients")
 * @ORM\Entity
 */
class Client extends BaseClient
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
    protected $name;

    public function __construct()
    {
        parent::__construct();
    }
    public function setName($name)
    {
        $this->name = $name;
    }
    public function getName()
    {
        return $this->name;
   }
}

所以,正如我所说,我扩展了具有 $ randomId的FOSOAuthServerBundle(\friendsofsymfony\oauth-server-bundle\Entity\Client.php,第 28 行)。现在我得到一个错误:

MappingException.php 第 565 行中的 MappingException:字段或鉴别器列映射中实体“Acme\ApiBundle\Entity\Client”上列“random_id”的重复定义。

我哪里错了?

4

1 回答 1

0

当我使用 时FOS\OAuthServerBundle\Entity\Client,我使用了一个扩展另一个目标类 ( FOS\OAuthServerBundle\Model\Client) 的类。有目标变量,例如我发现重复的 $RandomId。因此,根据我的观点,作为Acme\ApiBundle\Entity\Clientextends FOS\OAuthServerBundle\Entity\Clientwhich extends FOS\OAuthServerBundle\Model\Client,我们得到了两次变量而不是一次。所以我决定FOS\OAuthServerBundle\Model\Client直接扩展,它解决了我的问题。谁能解释为什么不可能以这种方式编写代码?

于 2016-08-15T14:45:53.660 回答