title: How can I inject callable into Symfon2 Dependency Injection Container service
body: <p>Given the the following class definition</p>
  
  <pre><code>class CacheSubscriber implements SubscriberInterface
  {
      public function __construct(
          CacheStorageInterface $cache,
          callable $canCache
      ) {
          $this-&gt;storage = $cache;
          $this-&gt;canCache = $canCache;
      }
  </code></pre>
  
  <p>I want to define this class as a service in Symfony2 DIC. </p>
  
  <p>While it is relatively clear what to do with the first argument</p>
  
  <pre><code>&lt;service id="nsp_generic.guzzle.subscriber.cache" class="GuzzleHttp\Subscriber\Cache\CacheSubscriber"&gt;
      &lt;argument type="service" id="nsp_generic.redis.cache"/&gt;
      &lt;!-- ??? --&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>How can I define and inject the second argument?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>User meckhardt pushed this into the right direction.</p>
  
  <p>Helper class</p>
  
  <pre><code>&lt;?php
  
  namespace Nsp\GenericBundle\Service\Cache;
  
  class CacheConfig {
      public static function canCache() {
          return true;
      }
  }
  </code></pre>
  
  <p>Service defintion</p>
  
  <pre><code>&lt;service id="nsp_generic.guzzle.subscriber.cache" class="GuzzleHttp\Subscriber\Cache\CacheSubscriber"&gt;
      &lt;argument type="service" id="nsp_generic.guzzle.subscriber.cache.storage"/&gt;
      &lt;argument type="collection"&gt;
          &lt;argument&gt;Nsp\GenericBundle\Service\Cache\CacheConfig&lt;/argument&gt;
          &lt;argument&gt;canCache&lt;/argument&gt;
      &lt;/argument&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p>Thanks Martin!</p>