Skip to content

[Messenger] Abstract handler #31417

@timiTao

Description

@timiTao

Symfony version(s) affected: ^4.2

Description

Currently, MessengerPass will compile the handler's definition that has class option. This option is needed to guess the handler's method and handles options.
If we use parent without class, then we get exception fromMessengerPass.

Proposition

If Definition implements ChildDefinition then we should get information from parent class.

Example
For global_bus will initialize correctly.
For command_bus will throw exception:

Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: Invalid service "command_bus": class "" does not exist. in /app/vendor/symfony/messenger/DependencyInjection/MessengerPass.php:85

services.yaml

  Symfony\Component\Messenger\MessageBus:
    abstract: true
    public: true
    class: Symfony\Component\Messenger\MessageBus
    arguments:
      - [] # Filled by MessengerPass

  global_bus:
    parent: Symfony\Component\Messenger\MessageBus
    tags:
      - { name: 'messenger.bus' }

# Due to MessengerPass, service marked as handler can't be abstract
  command_bus:
    parent: Symfony\Component\Messenger\MessageBus
    tags:
      - { name: 'messenger.bus'}
      - { name: 'messenger.message_handler', handles: 'Infrastructure\Command\Command',  method: 'dispatch', bus: 'global_bus'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy