Skip to content

Instantly share code, notes, and snippets.

@meshenka
Created May 7, 2019 12:10
Show Gist options
  • Save meshenka/c98d8b00b6ce380d96a3c92e1af1d455 to your computer and use it in GitHub Desktop.
Save meshenka/c98d8b00b6ce380d96a3c92e1af1d455 to your computer and use it in GitHub Desktop.
#config/packages/demo.yaml
parameters:
# see https://symfony.com/doc/current/configuration/environment_variables.html#environment-variable-processors
env(MY_DISPATCH_EVENTS): true
services:
App\Demo\DemoService:
bind:
$dispatchEvents: '%env(bool:MY_DISPATCH_EVENTS)%'
@Louzet
Copy link

Louzet commented May 7, 2019

si tu l'utilise dans tous les env, c'est une bonne chose de créer ton service à la racine /config/packages

demo.yaml

parameters:

see https://symfony.com/doc/current/configuration/environment_variables.html#environment-variable-processors

env(MY_DISPATCH_EVENTS): true
dispatchEvent: '%env(my_dispatch_events)%'

essais un ./bin/console debug:container --parameter dispatchEvents
pour t'assurer que ton parametre a été pris en compte.

Enfin, tu peut directement l'utiliser dans service.yaml:

services.yaml

services:
App\Demo\DemoService:
$dispatchEvent: '%dispatchEvent%'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment