2017 © Pedro Peláez
 

symfony-bundle catalyst-discriminator-map-bundle

Catalyst Doctrine Discriminator Map Bundle

image

jankstudio/catalyst-discriminator-map-bundle

Catalyst Doctrine Discriminator Map Bundle

  • Thursday, December 15, 2016
  • by jankstudio
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Catalyst Discriminator Map Bundle

Symfony bundle that allows the specification of Doctrine discriminator maps in bundle configuration files instead of under the parent entity., (*1)

This bundle removes the dependency of the parent entity on the children entities., (*2)

Configuration

Minimum requirement is to have a dmap.yml file under the Resources/config directory of the bundle with the parent entity., (*3)

Sample dmap.yml file:, (*4)

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:, (*5)

entities:
    - parent: MyBundle\Entity\Person
      children:
        - id: customer
          class: AnotherBundle\Entity\Customer

Discriminator Mapping Example

How discriminator mapping is normally done:

Entity:, (*6)

<?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:, (*7)

<?php
namespace MyProject\Entity;

/**
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 */
class Person
{
    // ...
}

/**
 * @Entity
 */
class Employee extends Person
{
    // ...
}

Configuration File (dmap.yml):, (*8)

entities:
    - parent: MyProject\Entity\Person
      children:
        - id: person
          class: MyProject\Entity\Person
        - id: employee
          class: MyProject\Entity\Employee

The Versions

15/12 2016

dev-master

9999999-dev https://github.com/jankstudio/catalyst-discriminator-map-bundle

Catalyst Doctrine Discriminator Map Bundle

  Sources   Download

MIT

The Requires

 

by Kendrick Chan

doctrine discriminator