phpoauth-2.0symfonyfosoauthserverbundle

Duplicate definition of column 'random_id' on entity 'Acme\ApiBundle\Entity\Client' in a field or discriminator column mapping


I created client which extends FOSOAuthServerBundle. The code of this client is the following:

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

So, as I said, I extend the FOSOAuthServerBundle which has $randomId (\friendsofsymfony\oauth-server-bundle\Entity\Client.php, line 28). Now I get an error:

MappingException in MappingException.php line 565: Duplicate definition of column 'random_id' on entity 'Acme\ApiBundle\Entity\Client' in a field or discriminator column mapping.

Where did I a mistake?


Solution

  • When I used FOS\OAuthServerBundle\Entity\Client, I used a class which extends another, target class (FOS\OAuthServerBundle\Model\Client). There were targeted variables, such as $RandomId which I found dublicate. So, according to my opinion, as Acme\ApiBundle\Entity\Client extends FOS\OAuthServerBundle\Entity\Client which extends FOS\OAuthServerBundle\Model\Client, we got variables twice instead of once. So I decided to extend FOS\OAuthServerBundle\Model\Client directly and it solves my issue. Can anyone explain why it is impossible to do code in a such way?