get getEnvironment() from a service
<p>In my notification service I have to send the notifications by mail, but in dev I want to send all the email to a specific adress:</p>

<pre><code>if ( $this-&gt;container-&gt;get('kernel')-&gt;getEnvironment() == "dev" ) {

    mail( 'mymail@mail.com', $lib, $txt, $entete );

} else {

    mail( $to-&gt;getEmail(), $lib, $txt, $entete );

}
</code></pre>

<p>But the <code>$this-&gt;container-&gt;get('kernel')-&gt;getEnvironment()</code> works only in a controller.</p>

<p>I think I have to add an argument in my service constructor:</p>

<pre><code>notification:
  class:      %project.notification.class%
  arguments: [@templating, @doctrine]
</code></pre>

<p>But I didn't find any information about this.</p>