jankstudio / catalyst-discriminator-map-bundle
Catalyst Doctrine Discriminator Map Bundle
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.4
- doctrine/doctrine-bundle: >=1.2
- doctrine/orm: >=2.2.3
- symfony/symfony: >=2.3
This package is not auto-updated.
Last update: 2025-04-21 17:46:17 UTC
README
Symfony bundle that allows the specification of Doctrine discriminator maps in bundle configuration files instead of under the parent entity.
This bundle removes the dependency of the parent entity on the children entities.
Configuration
Minimum requirement is to have a dmap.yml file under the Resources/config directory of the bundle with the parent entity.
Sample dmap.yml file:
entities:
- parent: MyBundle\Entity\Person
children:
- id: person
class: MyBundle\Entity\Person
- id: employee
class: MyBundle\Entity\Employee
You can have other dmap.yml files with the same parent entity in other bundles like so:
entities:
- parent: MyBundle\Entity\Person
children:
- id: customer
class: AnotherBundle\Entity\Customer
Discriminator Mapping Example
How discriminator mapping is normally done:
Entity:
<?php
namespace MyProject\Entity;
/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
*/
class Person
{
// ...
}
/**
* @Entity
*/
class Employee extends Person
{
// ...
}
How to do it with this bundle:
Entity:
<?php
namespace MyProject\Entity;
/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string")
*/
class Person
{
// ...
}
/**
* @Entity
*/
class Employee extends Person
{
// ...
}
Configuration File (dmap.yml):
entities:
- parent: MyProject\Entity\Person
children:
- id: person
class: MyProject\Entity\Person
- id: employee
class: MyProject\Entity\Employee