Im works in zend framework 2 project.
In fetch, All of my listener I have:
$artifacts = $this->documentManager->createQueryBuilder('App\Document\Artifact')
->hydrate(true)
->getQuery()
->execute();
$paginatorOrm = new DoctrinePaginator($artifacts);
$paginatorZend = new Paginator($paginatorOrm);
return $paginatorZend;
This code works fine, I can see a broken set of all artifacts. The problem is this:
- If hydrate (true): Doctrine ORM generates an AppDocumentArtifactHydrator.php file to hydrate the object, and I see in the output a paginated collection with all the information about all the artifacts.
- If hydrate (false): then I see a JSON structure with all artifact fields.
How to add your own hydrator to $ artifactsCollection? (In the collection for each artifact I want to specify only a name, identifier and a link to myself).
Months ago, I worked in a similar project using ZF2 + Doctrine 2 + MySQL, and I could create in onBootstrap
$entityManager->getConfiguration()->addCustomHydrationMode('MyHydrator', 'MyApp\Hydrators\MyEntity');
. , $entityManager $documentManager, .
?
!