Skip to content
Dynamic DiscriminatorMap extender for Symfony with Doctrine ORM.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DependencyInjection
EventListener
Resources/config
.gitignore
LICENSE
PedDiscriminatorMapBundle.php
README.md
composer.json

README.md

Welcome to Discriminator Map Bundle 👋

Version Documentation Twitter: dr_thief

Dynamic DiscriminatorMap extender for Symfony with Doctrine ORM.

🏠 Homepage

Installation

Step 1: Download the Bundle

Install via Composer:

composer require paneedesign/discriminator-map-bundle

Or add this to your composer.json and run composer update:

"require": {
    "paneedesign/discriminator-map-bundle": "^1.0"
}

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new \PaneeDesign\DiscriminatorMapBundle\PedDiscriminatorMapBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Configurations

Add configuration:

// app/config/config.yml
//...
ped_discriminator_map:
    maps:
        user:
            entity: PaneeDesign\UserBundle\Entity\User
            children:
                admin:    AppBundle\Entity\Admin
                owner:    AppBundle\Entity\Owner
                customer: AppBundle\Entity\Customer
                ...

where parent class implement this annotations:

/**
 * @ORM\Entity()
 * @ORM\Table(name="user")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="user_grant", type="string", length="10")
 * @ORM\DiscriminatorMap({"user" = "User"})
 */
abstract class User
{
    ...
}

and children class these one:

/**
 * Class Admin
 *
 * @package AppBundle\Entity
 * @ORM\Entity
 * @ORM\Table(name="user_admin")
 */
class Admin extends User
{
    ...
}
/**
 * Class Owner
 *
 * @package AppBundle\Entity
 * @ORM\Entity()
 * @ORM\Table(name="user_owner")
 */
class Owner
{
    ...
}
/**
 * Class Customer
 *
 * @package AppBundle\Entity
 * @ORM\Entity()
 * @ORM\Table(name="user_customer")
 */
class Customer
{
    ...
}

Author

👤 Fabiano Roberto

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

You can’t perform that action at this time.