title: Doctrine2 custom hydrator for single entity
body: <p>I have an entity that requires custom hydration logic. I'm trying to create a custom Doctrine2 hydrator for that entity. Project is written with Symfony3, so I wrote a simple one:</p>
  
  <pre><code>final class CustomHydrator extends AbstractHydrator
  {
      protected function hydrateAllData()
      {
          return array_map(function(array $data) {
              // I'm doing that custom logic here
              $computedData = /* ... */
              return new EntityClass($computedData);
          }, $this-&gt;_stmt-&gt;fetchAll(\PDO::FETCH_ASSOC));
      }
  }
  </code></pre>
  
  <p>That hydrator was registered in <code>config.yml</code>:</p>
  
  <pre><code>orm:
    entity_managers:
      default:
        hydrators: [CustomHydrator]
  </code></pre>
  
  <p>Unfortunately it is not called anywhere and I failed to find any documentation that would explain the process of hooking hydrators in Doctrine.</p>
  
  <p>The question is: <strong>how to create custom Doctrine hydrator so that a single entity or a subset of mapped entities would be automatically hydrated this way?</strong></p>