Skip to content

EntityListener can't be applied to multiple services with same class name #1224

@biozshock

Description

@biozshock

With current implementation of ContainerEntityListenerResolver it's not possible to use same class, even if it has different service IDs

Consider following config:

services:
  service_a:
    class: My\Class
    parameters: ['param1`]
    tags:
      - {'name': 'doctrine.orm.entity_listener', 'entity': 'My\Entity1'}

  service_b:
    class: My\Class
    parameters: ['param2`]
    tags:
      - {'name': 'doctrine.orm.entity_listener', 'entity': 'My\Entity2'}

The entity listener service_b will be applied to entity My\Entity1, because https://github.com/doctrine/DoctrineBundle/blob/2.1.2/Mapping/ContainerEntityListenerResolver.php#L66 uses class name instead of the service ID to collect entity listeners.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions