Answer the question
In order to leave comments, you need to log in
How to disable inheritance in Doctrine?
How can I disable inheritance in doctrine? That is, so that doctrina does not check mapping and works with these classes as with ordinary classes without extends.
I only need inheritance in this situation to inherit some methods that I do not want to be called directly from the parent.
UPD:
I tried using the InheritanceType("JOINED") approach, but it throws me an error
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
which I can't trace.
Here is an example of simplified classes.
/**
* Parent
* @ORM\Table(blablabla)
* @ORM\Entity
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({
* "parent" = "App\Model\Parent\Parent",
* "children" = "App\Model\Children\Children"
* })
*/
class Parent
{
/**
* @var Id
*
* @ORM\Column(name="id_parent", type="parent_id", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
protected $id;
//другие поля.
protected function __construct(Id $id, ........)
{
///...... init
}
}
/**
* Children
*
* @ORM\Table(blablabla)
* @ORM\Entity
*/
class Children extends Parent
{
/**
* @var Parent
*
* @ORM\OneToOne(targetEntity="App\Model\Parent\Parent", cascade={"persist", "remove"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_parent", referencedColumnName="id_parent", onDelete="CASCADE")
* })
*/
private $item;
/**
* @var SomeClassForChilder|null
*
* @ORM\OneToOne(targetEntity="App\Model\SomeClassForChilder\SomeClassForChilder",
* mappedBy="children", cascade={"persist"})
*/
private $someClassForChilder;
//другие поля.
public function __construct(Id $id, ........)
{
parent::__construct(Id $id, ....);
$this->someClassForChilder = new SomeClassForChilder($this)
///...... init
}
}
/**
* SomeClassForChilder
*
* @ORM\Table(blablabla)
* @ORM\Entity
*/
class SomeClassForChilder
{
/**
* @var Children
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="App\Model\Children\Children",
* inversedBy="someClassForChilder", cascade={"persist", "remove"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_parent", referencedColumnName="id_parent", onDelete="CASCADE")
* })
*/
private $children;
public function __construct(Children $children)
{
///...... init
}
}
$children = new Children($id, ....);
persist(children )
flash...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question