Reputation: 565
i have an already created symfony bundle. i wanted to add another bundle for my application separately. so now im facing a problem that how to extend an entity from old bundle to newly created one. i extended it normally but it giving errors.
i have these 2 bundles,
MyFirstBundle
MySecondBundle
MyFirstBundle entity,
namespace My\FirstBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
*
* @ORM\Table(name="companies")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class Company
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*
* @Groups({"list_companies", "company_details", "ad_details"})
*/
private $id;
/**
* @ORM\Column(name="name", type="string", length=50, nullable=true)'
*
* @Groups({"ad_details"})
*/
private $name;
MySecondBundle Entity,
namespace My\SecondBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use My\FirstBundle\Entity\Company as BaseCompany;
class Companies extends BaseCompany
{
public function __construct() {
parent::__construct();
}
}
im not sure that i can extend my entity like this. im getting error when creating forms with this entity
Class "MySecondBundle:companies" seems not to be a managed Doctrine entity. Did you forget to map it?
Upvotes: 0
Views: 449
Reputation: 2187
You need to add the doctrine annotations for the second entity as well.
/**
*
* @ORM\Table(name="companies")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class Companies extends BaseCompany
{
public function __construct() {
parent::__construct();
}
}
Upvotes: 1