DoctrineBehaviors
DoctrineBehaviors copied to clipboard
Using InheritanceType
Hi there,
I have a discrimator inheritance :
/**
* @ORM\Entity
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"activity" = "Activity", "meals" = "Meal", "bookable_table" = "BookableTable"})
*/
abstract class AbstractBookableActivity extends AbstractEntity implements TranslatableInterface
{
use TranslatableTrait;
}
With an entity that extends the abstract entity
/**
* @ORM\Entity(repositoryClass="App\Repository\ActivityRepository")
*/
class Activity extends AbstractBookableActivity
{
}
Now I will create the translation object
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait;
use Symfony\Component\Serializer\Annotation as Serializer;
/**
* @ORM\Entity
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"activity" = "ActivityTranslation", "meals" = "MealTranslation", "bookable_table" = "BookableTableTranslation"})
*/
abstract class AbstractBookableActivityTranslation extends AbstractEntity implements TranslationInterface
{
use TranslationTrait;
/**
* @ORM\Column(type="string")
*/
#[Serializer\Groups(['trace_change'])]
public string $name = '';
/**
* @ORM\Column(type="text", nullable=true)
*/
#[Serializer\Groups(['trace_change'])]
public ?string $description = null;
/**
* @ORM\Column(type="text", nullable=true)
*/
#[Serializer\Groups(['trace_change'])]
public ?string $smallDescription = null;
}
And activity translation :
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class ActivityTranslation extends AbstractBookableActivityTranslation
{
}
But it's not working too, in insert, discr
is always null.
How can we do to correct this issue ?
I followed this commit https://github.com/KnpLabs/DoctrineBehaviors/pull/688/files
I posted an issue on doctrine. Can you check this ?