exchangeArray() public méthode

public exchangeArray ( array $data )
$data array
 public function exchangeArray(array $data)
 {
     parent::exchangeArray($data);
     foreach ($data as $key => $value) {
         $key = strtolower($key);
         $key = str_replace('_', '', $key);
         switch ($key) {
             case 'servicename':
                 $this->serviceName = $value;
                 break;
         }
     }
     if (null === $this->serviceName) {
         throw new CreationException('No service name provided; cannot create RESTful resource', 422);
     }
     if (null === $this->routeIdentifierName) {
         $this->routeIdentifierName = sprintf('%s_id', $this->normalizeServiceNameForIdentifier($this->serviceName));
     }
     if (null === $this->routeMatch) {
         $this->routeMatch = sprintf('/%s', $this->normalizeServiceNameForRoute($this->serviceName));
     }
     if (null === $this->collectionName) {
         $this->collectionName = $this->normalizeServiceNameForIdentifier($this->serviceName);
     }
 }
 public function exchangeArray(array $data)
 {
     parent::exchangeArray($data);
     foreach ($data as $key => $value) {
         $key = strtolower($key);
         $key = str_replace('_', '', $key);
         switch ($key) {
             case 'hydrator':
                 $this->hydratorName = $value;
                 break;
             case 'objectmanager':
                 $this->objectManager = $value;
                 break;
             case 'byvalue':
                 $this->byValue = $value;
                 break;
             case 'strategies':
                 $this->hydratorStrategies = $value;
                 break;
             case 'usegeneratedhydrator':
                 $this->useGeneratedHydrator = $value;
                 break;
             case 'servicename':
                 $this->serviceName = $value;
                 break;
         }
     }
 }
 /**
  * @param RestServiceEntity $service
  */
 protected function injectDocumentation(RestServiceEntity $service)
 {
     $documentation = $this->documentationModel->fetchDocumentation($this->moduleName, $service->controllerServiceName);
     if (!$documentation) {
         return;
     }
     $entity = new HalEntity($documentation, 'documentation');
     $service->exchangeArray(['documentation' => $entity]);
 }
 /**
  * Merge the content negotiation configuration for the given controller
  * service into the REST metadata
  *
  * @param  string $controllerServiceName
  * @param  RestServiceEntity $metadata
  * @param  array $config
  */
 protected function mergeContentNegotiationConfig($controllerServiceName, RestServiceEntity $metadata, array $config)
 {
     if (!isset($config['zf-content-negotiation'])) {
         return;
     }
     $config = $config['zf-content-negotiation'];
     if (isset($config['controllers'][$controllerServiceName])) {
         $metadata->exchangeArray(['selector' => $config['controllers'][$controllerServiceName]]);
     }
     if (isset($config['accept_whitelist'][$controllerServiceName])) {
         $metadata->exchangeArray(['accept_whitelist' => $config['accept_whitelist'][$controllerServiceName]]);
     }
     if (isset($config['content_type_whitelist'][$controllerServiceName])) {
         $metadata->exchangeArray(['content_type_whitelist' => $config['content_type_whitelist'][$controllerServiceName]]);
     }
 }
 /**
  * @group 170
  */
 public function testUpdateRestWillUpdateCollectionName()
 {
     $details = $this->getCreationPayload();
     $original = $this->codeRest->createService($details);
     $options = ['collection_name' => 'foo_bars'];
     $patch = new RestServiceEntity();
     $patch->exchangeArray($options);
     $this->codeRest->updateRestConfig($original, $patch);
     $config = (include __DIR__ . '/TestAsset/module/BarConf/config/module.config.php');
     $this->assertArrayHasKey('zf-rest', $config);
     $this->assertArrayHasKey($original->controllerServiceName, $config['zf-rest']);
     $test = $config['zf-rest'][$original->controllerServiceName];
     foreach ($options as $key => $value) {
         $this->assertEquals($value, $test[$key]);
     }
 }
    /**
     * @group 166
     */
    public function testOnFetchWillRetainResourceClassIfEventFetchFlagIsFalse()
    {
        $originalData = array(
            'controller_service_name' => 'BarConf\Rest\Barbaz\Controller',
            'resource_class'          => 'BarConf\Rest\Barbaz\BarbazResource',
            'route_name'              => 'bar-conf.rest.barbaz',
            'route_match'             => '/api/barbaz',
            'entity_class'            => 'BarConf\Rest\Barbaz\BarbazEntity',
        );
        $entity = new RestServiceEntity();
        $entity->exchangeArray($originalData);
        $config = array( 'zf-apigility' => array('db-connected' => array(
            'BarConf\Rest\Barbaz\BarbazResource' => array(
                'adapter_name'  => 'Db\Barbaz',
                'table_name'    => 'barbaz',
                'hydrator_name' => 'ObjectProperty',
            ),
        )));

        $event = new Event();
        $event->setParam('entity', $entity);
        $event->setParam('config', $config);
        $event->setParam('fetch', false);
        $result = $this->model->onFetch($event);

        $this->assertInstanceOf('ZF\Apigility\Admin\Model\DbConnectedRestServiceEntity', $result);
        $this->assertEquals('BarConf\Rest\Barbaz\BarbazResource', $result->resourceClass);
        $asArray = $result->getArrayCopy();
        $this->assertArrayHasKey('resource_class', $asArray);
        $this->assertEquals('BarConf\Rest\Barbaz\BarbazResource', $asArray['resource_class']);
    }
 /**
  * @param Model\RestServiceEntity|Model\RpcServiceEntity $entity
  * @param EventInterface $e
  * @return void
  */
 private function injectServiceCollectionRelationalLinks($entity, EventInterface $e)
 {
     $entity->exchangeArray(['controller_service_name' => str_replace('\\', '-', $entity->controllerServiceName)]);
     $module = $this->routeMatch->getParam('name');
     $service = $entity->controllerServiceName;
     $type = $this->getServiceType($service);
     $halEntity = new Entity($entity, $service);
     $links = $halEntity->getLinks();
     // Need to inject the self relational link, as otherwise the HAL plugin
     // sees we have links, and does not inject one.
     $links->add(Link::factory(['rel' => 'self', 'route' => ['name' => sprintf('zf-apigility/api/module/%s-service', $type), 'params' => ['name' => $module, 'controller_service_name' => $service]]]));
     // Add the input_filter relational link
     $links->add(Link::factory(['rel' => 'input_filter', 'route' => ['name' => sprintf('zf-apigility/api/module/%s-service/input-filter', $type), 'params' => ['name' => $module, 'controller_service_name' => $service]]]));
     // Add the documentation relational link
     $links->add(Link::factory(['rel' => 'documentation', 'route' => ['name' => sprintf('zf-apigility/api/module/%s-service/doc', $type), 'params' => ['name' => $module, 'controller_service_name' => $service]]]));
     $e->setParam('entity', $halEntity);
 }