liip / LiipMonitorBundle

Integrates the LiipMonitor library into Symfony
http://liip.ch
467 stars 103 forks source link

Register argument name aliases #272

Closed IonBazan closed 2 years ago

IonBazan commented 2 years ago

Registers Runner services for each check group as named argument aliases. It is now possible to inject a specific runner into a controller or other service by naming the argument to match the group name:

public function __construct(private Runner $fooRunner) {} // Injects liip_monitor.runner_foo

public function __construct(private Runner $defaultRunner) {} // Injects liip_monitor.runner_default

public function __construct(private Runner $runner) {} // Injects liip_monitor.runner (alias of liip_monitor.runner_default)

This is a common practice in Symfony world, used for example in symfony/http-client or league/flysystem-bundle.

kbond commented 2 years ago

Should Runner be an alias for the default runner? Should your third example above just inject the default runner? I believe that's how (at least) symfony/http-client works.

kbond commented 2 years ago

Thanks!