列的重复定义' random_id'实体' Acme \ ApiBundle \ Entity \ Client'在字段或鉴别器列映射中

时间:2016-08-15 10:58:04

标签: php oauth-2.0 symfony fosoauthserverbundle

我创建了扩展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;
   }
}

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

  

MappingException.php第565行中的MappingException:   列的重复定义&#39; random_id&#39;实体&#39; Acme \ ApiBundle \ Entity \ Client&#39;在字段或鉴别器列映射中。

我在哪里犯了错误?

1 个答案:

答案 0 :(得分:0)

当我使用FOS\OAuthServerBundle\Entity\Client时,我使用了一个扩展另一个目标类(FOS\OAuthServerBundle\Model\Client)的类。有针对性的变量,比如我发现的$ RandomId。所以,根据我的观点,当Acme\ApiBundle\Entity\Client扩展FOS\OAuthServerBundle\Entity\Client扩展FOS\OAuthServerBundle\Model\Client时,我们得到两次变量而不是一次。所以我决定直接延长FOS\OAuthServerBundle\Model\Client,它解决了我的问题。任何人都可以解释为什么不可能以这种方式做代码吗?