PHPackages                             ojezu/configurable-discrimination-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ojezu/configurable-discrimination-bundle

ActiveLibrary[Database &amp; ORM](/categories/database)

ojezu/configurable-discrimination-bundle
========================================

Symfony2 bundle that allows configuring Doctrine discrimination maps in children bundles.

v2.0.0(8y ago)07.7k1[1 PRs](https://github.com/OJezu/configurable-discrimination-bundle/pulls)MITPHP

Since Nov 12Pushed 7y ago1 watchersCompare

[ Source](https://github.com/OJezu/configurable-discrimination-bundle)[ Packagist](https://packagist.org/packages/ojezu/configurable-discrimination-bundle)[ RSS](/packages/ojezu-configurable-discrimination-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (7)Used By (0)

OJezu/ConfigurableDiscriminationBundle
======================================

[](#ojezuconfigurablediscriminationbundle)

This Bundle solves Doctrine problem with inheritance: discriminatorMap has to be declared on parent entity, and has to have all children declared in it. If you leave it empty, Doctrine will scan ALL files to look for classes that extend the parent class, and will auto-generate entries for them in discriminatorMap along with discriminator values - over which programmer in that case has absolutely no control - they will be derived from name of child class and that's it.

That is especially nasty, if some of the children classes are in other bundles, programmer has to make the parent bundle aware of all the child classes!

This Bundle allows specifying discriminator values and children classes in child bundle configuration - making the code of parent bundle clear of any references to children bundles, avoids scanning all class files in search of children classes and allows specifying custom discriminator values.

Installation
============

[](#installation)

```
composer require ojezu/configurable-discrimination-bundle
```

Usage
=====

[](#usage)

Register this bundle in app/appKernel.php:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new OJezu\ConfigurableDiscriminationBundle\ConfigurableDiscriminationBundle(),
            // app bundles
            new Acme\TestBundle\ParentBundle(),
            new Acme\TestBundle\ChildABundle(),
            new Acme\TestBundle\ChildBBundle(),
        );
        return $bundles;
    }
}
```

In ParentBundle:
================

[](#in-parentbundle)

You have to declare non-empty discriminatorMap or otherwise Doctrine will try to auto-generate it. OJezu/ConfigurableDiscriminationBundle will only add entries to it.

```
#Acme/AcmeParent/Entity/AcmeParent.php

/**
 * (...)
 * @ORM\DiscriminatorMap({"base" = "AcmeParent"})
 */
class AcmeParent
{
    (...)
}
```

In ChildABundle:
================

[](#in-childabundle)

Add some faux-services tagged with `ojezu.configurable_discrimination` to your bundle internal config so that OJezu/ConfigurableDiscriminationBundle can read your custom configuration.

Name of the service does not matter.

```
# service.yml
services:
    acme.acme_entity.acme_child_a:
        class: 'Acme\AcmeChildA\Entity\AcmeChildA'
        public: false
        tags:
            - name: ojezu.configurable_discrimination
              discriminator_value: 'acme_child_a'
```

`Acme\AcmeChildA\Entity\AcmeChildA` of course must be defined, and directly extend `Acme\AcmeParent\Entity\AcmeParent`

In ChildBBundle:
================

[](#in-childbbundle)

```
# service.yml
services:
    acme.acme_entity.acme_child_b:
        class: 'Acme\AcmeChildB\Entity\AcmeChildB'
        public: false
        tags:
            - name: ojezu.configurable_discrimination
              discriminator_value: 'acme_child_b'
```

Acknowledgments
===============

[](#acknowledgments)

Thanks to  who helped me to get into Symfony and did some code reviewing of this package.

This package is somewhat based on [DCSDynamicDiscriminatorMapBundle](https://github.com/damianociarla/DCSDynamicDiscriminatorMapBundle)and on [Defining Discriminator Maps at Child-level in Doctrine 2](https://medium.com/@jasperkuperus/defining-discriminator-maps-at-child-level-in-doctrine-2-1cd2ded95ffb)

License
=======

[](#license)

MIT

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity67

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~179 days

Total

5

Last Release

3113d ago

Major Versions

v1.2.0 → v2.0.02017-10-30

### Community

Maintainers

![](https://www.gravatar.com/avatar/2dd2fd22b17ab8ee5da28e496df93327d1920b75bbccb98d76bc4e933f5f5815?d=identicon)[ojezu](/maintainers/ojezu)

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ojezu-configurable-discrimination-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ojezu-configurable-discrimination-bundle/health.svg)](https://phpackages.com/packages/ojezu-configurable-discrimination-bundle)
```

###  Alternatives

[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[pixelfederation/doctrine-resettable-em-bundle

Symfony bundle for decorating default entity managers using a resettable decorator.

20113.5k](/packages/pixelfederation-doctrine-resettable-em-bundle)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1183.0k1](/packages/bartlett-php-compatinfo-db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
