I’m currently building Entity model and one of my Doctrine Entities have ManyToMany relation with an external dictionary (like ENUM). So the entity field will be an Array of Enum.
I’m looking for a way to have it as an array field on my entity, but to store it as a separate DB table.
Would like to get any advice/links/etc.
Advertisement
Answer
Finally, I’ve decided to create an Entity to store this relation. To make sure it will be deleted on unlinking from the parent entity, I’ve used the orphanRemoval=true
option on the OneToMany relation side.
class Entity { /** * @ORMOneToMany(targetEntity="EntityType", mappedBy="entity", orphanRemoval=true) */ protected $types; } class EntityType { /** * @ORMManyToOne(targetEntity="Entity") */ protected $entity; /** * @ORMColumn(type="MyEnum") */ protected MyEnum $type; }