Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Last active October 2, 2022 12:59
Show Gist options
  • Save ismail1432/2e1327018a16aadcb65725e95dff1c28 to your computer and use it in GitHub Desktop.
Save ismail1432/2e1327018a16aadcb65725e95dff1c28 to your computer and use it in GitHub Desktop.
# services.yaml
services:
_instanceof:
# Add a tag `app.pre_handler` to all classes that implements App\PreHandlerInterface
App\PreHandlerInterface:
tags: [ 'app.pre_handler' ]
# Add a tag `app.post_handler` to all classes that implements App\PostHandlerInterface
App\PostHandlerInterface:
tags: [ 'app.post_handler' ]
_defaults:
autowire: true
autoconfigure: true
bind:
# Bind a variable $preHandlers, it contains an iterator
# of all classes with tag app.pre_handler
# this variables will be injected in `Bus`
$preHandlers: !tagged_iterator app.pre_handler
# bind a variable $postHandlers, it contains an iterator
# of all classes with tag app.post_handler
# this variables will be injected in `Bus`
$postHandlers: !tagged_iterator app.post_handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment