/** * Create Doctrine hydrator configuration * * @param DoctrineRestServiceEntity $details * @param string $entityClass * @param string $collectionClass * @param string $routeName * @throws CreationException */ public function createDoctrineHydratorConfig(DoctrineRestServiceEntity $details, $entityClass, $collectionClass, $routeName) { $entityValue = $details->getArrayCopy(); // Verify the object manager exists $objectManager = $this->getServiceManager()->get($details->objectManager); $hydratorStrategies = isset($entityValue['strategies']) ? $entityValue['strategies'] : []; foreach ($hydratorStrategies as $strategy) { if (!$this->getServiceManager()->has($strategy)) { throw new CreationException('Invalid strategy specified. Must be declared in the service manager.'); } } // The abstract_factories key is set to the value so these factories do not get duplicaed with each resource $config = ['doctrine-hydrator' => [$details->hydratorName => ['entity_class' => $entityClass, 'object_manager' => $details->objectManager, 'by_value' => $entityValue['by_value'], 'strategies' => $hydratorStrategies, 'use_generated_hydrator' => $entityValue['use_generated_hydrator']]]]; $this->configResource->patch($config, true); }