title: Pick interface implementation based on parameter in Symfony config
body: <p>Lets suppose I have an interface <code>ThingInterface</code> and two implementations <code>Thing</code> and <code>MockThing</code>. Now assuming I am using dependency injection and I have programmed against <code>ThingInterface</code> then in symfony I can tell it which implementation to use, as follows:</p>
  
  <pre><code>services:
      ...
      ThingInterface: '@Thing'
      ...
  </code></pre>
  
  <p>Is it possible to pick and implementation to use based on a parameter? E.g:</p>
  
  <pre><code>parameters:
      useMock: 'true'
  
  services:
      ...
      # ThingInterface maps to ThingMock or Thing based on useMock parameter
      ThingInterface: '@ThingMock'
      ...
  </code></pre>
  
  <p>I'm using <strong>symfony 3.4</strong>.</p>
  
  <p>The context here is that I'll have a number of services, and I want to easily switch between an actual implementation and mocked version. I can do this individually for each service, but I was hoping I can do this through a parameter 'toggle'.</p>
  
  <p>I found <a href="https://symfony.com/doc/3.4/service_container/expression_language.html" rel="nofollow noreferrer">this</a> which gives this example:</p>
  
  <pre><code>services:
      AppBundle\Mailer:
          arguments: ["@=container.hasParameter('some_param') ? parameter('some_param') : 'default_value'"]
  </code></pre>
  
  <p>But I have been unable to make it work for mapping interfaces to implementations:</p>
  
  <pre><code>parameters:
      useMock: 'true'
  
  services:
      ...
      # ThingInterface maps to ThingMock or Thing based on useMock parameter
      ThingInterface: '@ThingMock'
      ThingInterface: ["@=container.getParameter('useMock') ? service('ThingMock') : service('Thing')"]
      ...
  </code></pre>