Provides the possibility to extend DiscriminatorMap on an Inheritance Mapped class with Class Table Inheritance in Symfony2 with Doctrine ORM 2.
This bundle was intended to extend an existing DiscriminatorMap (comes from any mapping) through the config file, if you can't do it by hand (ie: the bundle you want to extend is developed outside your project).
// composer.json
{
"require": {
...
"netpositive/discriminatormap-bundle": "dev-master"
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Netpositive\DiscriminatorMapBundle\NetpositiveDiscriminatorMapBundle(),
[NetpositiveDiscriminatorMapBundle]
git=git://github.com/Netpositive/NetpositiveDiscriminatorMapBundle.git
target=bundles/Netpositive/DiscriminatorMapBundle
// app/autoload.php
$loader->registerNamespaces(array(
...
'Netpositive' => __DIR__.'/../vendor/bundles',
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
...
new Netpositive\DiscriminatorMapBundle\NetpositiveDiscriminatorMapBundle(),
# app/config/config.yml
netpositive_discriminator_map:
discriminator_map:
content:
entity: Netpositive\CmsBundle\Entity\Content
children:
course: University\CmsBundle\Entity\Content\Course
phonebook_entry: University\CmsBundle\Entity\Content\PhonebookEntry
...
/**
* Netpositive\CmsBundle\Entity\Content
*
* @ORM\Table(name="content")
* @ORM\Entity()
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="content_type", type="string", length="20")
* @ORM\DiscriminatorMap({"content" = "Content", "article" = "Article", ... })
*
*/
class Content
{
...
/**
* University\CmsBundle\Entity\Content\Course
*
* @ORM\Table(name="course")
* @ORM\Entity()
*/
class Course extends Content
{
...
/**
* University\CmsBundle\Entity\Content\PhonebookEntry
*
* @ORM\Table(name="phonebook_entry")
* @ORM\Entity()
*/
class PhonebookEntry extends Content
{
...