title: Injecting parameter based service into other service
body: <p>I have a service which takes a driver to do the actual work. The driver itself is within the context of Symfony 2 is just another service.</p>
  
  <p>To illustrate a simplified version:</p>
  
  <pre><code>services:
    # The driver services.
    my_scope.mailer_driver_smtp:
      class: \My\Scope\Service\Driver\SmtpDriver
  
    my_scope.mailer_driver_mock:
      class: \My\Scope\Service\Driver\MockDriver
  
    # The actual service.
    my_scope.mailer:
      class: \My\Scope\Service\Mailer
      calls:
        - [setDriver, [@my_scope.mailer_driver_smtp]]
  </code></pre>
  
  <p>As the above illustrates, I can inject any of the two driver services into the Mailer service. The problem is of course that the driver service being injected is hard coded. So, I want to parameterize the <code>@my_scope.mailer_driver_smtp</code>.</p>
  
  <p>I do this by adding an entry to my <code>parameters.yml</code></p>
  
  <pre><code>my_scope_mailer_driver: my_scope.mailer_driver_smtp
  </code></pre>
  
  <p>I can then use this in my <code>config.yml</code> and assign the parameter to the semantic exposed configuration [1]:</p>
  
  <pre><code>my_scope:
    mailer:
      driver: %my_scope_mailer_driver%
  </code></pre>
  
  <p>In the end, in the <code>Configuration</code> class of my bundle I set a parameter onto the container:</p>
  
  <pre><code>$container-&gt;setParameter('my_scope.mailer.driver', $config['mailer']['driver'] );
  </code></pre>
  
  <p>The value for the container parameter <code>my_scope.mailer.driver</code> now equals the <code>my_scope.mailer_driver_smtp</code> that I set in the <code>parameters.yml</code>, which is, as my understanding of it is correct, just a string.</p>
  
  <p>If I now use the parameter name from the container I get an error complaining that there is no such service. E.g:</p>
  
  <pre><code>services:
    my_scope.mailer:
      class: \My\Scope\Service\Mailer
      calls:
        - [setDriver, [@my_scope.mailer.driver]]
  </code></pre>
  
  <p>The above will result in an error:</p>
  
  <pre><code>[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                                          
  The service "my_scope.mailer" has a dependency on a non-existent service "my_scope.mailer.driver"
  </code></pre>
  
  <p>The question now is, what is the correct syntax to inject this container parameter based service? </p>
  
  <p>[1] <a href="http://symfony.com/doc/current/cookbook/bundles/extension.html" rel="noreferrer">http://symfony.com/doc/current/cookbook/bundles/extension.html</a></p>