get getEnvironment() from a service
There is no need to inject container. In fact, it is not a good idea to inject container because you’re making your class dependent on the DI. You should inject environment parameter: services.yml notification: class: NotificationService arguments: [“%kernel.environment%”] NotificationService.php <?php private $env; public function __construct($env) { $this->env = $env; } public function mailStuff() { if … Read more