2017 © Pedro Peláez
 

library dynamic-discriminator-map-bundle

DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.

image

damianociarla/dynamic-discriminator-map-bundle

DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.

  • Sunday, May 14, 2017
  • by damianociarla
  • Repository
  • 1 Watchers
  • 12 Stars
  • 13,608 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 4 Versions
  • 10 % Grown

The README.md

DynamicDiscriminatorMapBundle

DynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table and Class Table Inheritance mapping strategy in Symfony2, (*1)

With this bundle you can adds dynamically all classes of a hierarchy to the options of DiscriminatorMap using a config file. This way you can apply the methodology of 'decoupling', (*2)

Installation

Step 1: Download DynamicDiscriminatorMapBundle using composer

Add DynamicDiscriminatorMapBundle in your composer.json:, (*3)

{
    "require": {
        "damianociarla/dynamic-discriminator-map-bundle": "dev-master"
    }
}

Step 2: Enable the bundle

Enable the bundle in the kernel:, (*4)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new DCS\DynamicDiscriminatorMapBundle\DCSDynamicDiscriminatorMapBundle(),
    );
}

Configuration

Parent class

This is an example of a parent class, (*5)

<?php
namespace Acme\PersonBundle\Entity;

/**
 * @ORM\Entity
 * @ORM\Table(name="person")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"person" = "Person"})
 */
class Person
{
    // ...
}

Children classes

This is an example of two children classes, (*6)

<?php
namespace Acme\StudentBundle\Entity;

use Acme\PersonBundle\Entity\Person;

/**
 * @ORM\Entity
 */
class Student extends Person
{
    // ...
}

<?php
namespace Acme\TeacherBundle\Entity;

use Acme\PersonBundle\Entity\Person;

/**
 * @ORM\Entity
 */
class Teacher extends Person
{
    // ...
}

Configuration file

# app/config/config.yml
dcs_dynamic_discriminator_map:
    mapping:
        person:
            entity: Acme\PersonBundle\Entity\Person
            map:
                student: Acme\StudentBundle\Entity\Student
                teacher: Acme\TeacherBundle\Entity\Teacher

The Versions

14/05 2017

dev-master

9999999-dev https://github.com/damianociarla/DCSDynamicDiscriminatorMapBundle

DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.

  Sources   Download

MIT

The Requires

 

symfony2 doctrine entity inheritance mapping

01/03 2016

v1.0.2

1.0.2.0 https://github.com/damianociarla/DCSDynamicDiscriminatorMapBundle

DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.

  Sources   Download

MIT

The Requires

 

symfony2 doctrine entity inheritance mapping

24/08 2014

v1.0.1

1.0.1.0 https://github.com/damianociarla/DCSDynamicDiscriminatorMapBundle

DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.

  Sources   Download

MIT

The Requires

 

symfony2 doctrine entity inheritance mapping

18/12 2013

v1.0

1.0.0.0 https://github.com/damianociarla/DCSDynamicDiscriminatorMapBundle

DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.

  Sources   Download

MIT

The Requires

 

symfony2 doctrine entity inheritance mapping