ZF\Apigility\Doctrine\Admin\Model\DoctrineRestServiceEntity::getArrayCopy PHP Method

getArrayCopy() public method

public getArrayCopy ( )
    public function getArrayCopy()
    {
        $data = parent::getArrayCopy();
        $data['hydrator_name'] = $this->hydratorName;
        $data['object_manager'] = $this->objectManager;
        $data['by_value'] = $this->byValue;
        $data['strategies'] = $this->hydratorStrategies;
        $data['use_generated_hydrator'] = $this->useGeneratedHydrator;
        return $data;
    }

Usage Example

 /**
  * 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);
 }
DoctrineRestServiceEntity