title: How to register a Delegator Factory for a Hydrator in Zend Framework 2?
body: <p><a href="http://ocramius.github.io/blog/zend-framework-2-delegator-factories-explained/" rel="nofollow">Delegator Factories</a> in Zend Framework 2 are a powerful tool to hook into the creating of standard ZF objects and change or even completely replcae them by custom ones.</p>
  
  <p>I want to create a Delegator Factory for a Hydrator, in order to attach some Hydrator Strategies to it. But it's not working yet...</p>
  
  <p><strong><code>module.config.php</code></strong></p>
  
  <pre><code>return array(
      ...
      'service_manager' =&gt; array(
          ...
          'invokables' =&gt; array(
              ...
              'AuthenticationAdapterDelegatorFactory' =&gt; 'Foo\\MvcAuth\\Factory\\AuthenticationAdapterDelegatorFactory', // &lt;-- it works
              'DoctrineObjectHydratorDelegatorFactory' =&gt; 'Bar\\Model\\Entity\\Hydrator\\DoctrineObjectHydratorDelegatorFactory', // &lt;-- it doesn't
          ),
          'delegators' =&gt; array(
              'ZF\\MvcAuth\\Authentication\\DefaultAuthenticationListener' =&gt; array( // &lt;-- it works
                  0 =&gt; 'AuthenticationAdapterDelegatorFactory',
              ),
              'DoctrineModule\\Stdlib\\Hydrator\\DoctrineObject' =&gt; array( // &lt;-- it doesn't
                  0 =&gt; 'DoctrineObjectHydratorDelegatorFactory'
              )
          ),
      ),
      ...
  );
  </code></pre>
  
  <p>Since hydrators are actually provided by the <code>HydratorPluginManager</code>, I've also tried it this way:</p>
  
  <pre><code>return array(
      'service_manager' =&gt; array(
          ...
          'invokables' =&gt; array(
              ...
              'DoctrineObjectHydratorDelegatorFactory' =&gt; 'Bar\\Model\\Entity\\Hydrator\\DoctrineObjectHydratorDelegatorFactory',
          ),
          'delegators' =&gt; array(
              ...
              'DoctrineModule\\Stdlib\\Hydrator\\DoctrineObject' =&gt; array( // &lt;-- it doesn't
                  0 =&gt; 'DoctrineObjectHydratorDelegatorFactory'
              )
          ),
      ),
      'hydrator_manager' =&gt; array(
          'delegators' =&gt; array(
              'DoctrineModule\\Stdlib\\Hydrator\\DoctrineObject' =&gt; array(
                  0 =&gt; 'DoctrineObjectHydratorDelegatorFactory'
              )
          ),
      ),
  );
  </code></pre>
  
  <p>So what is going wrong here and how can I register a Delegator Factory for a Hydrator in Zend Framework 2?</p>