コード例 #1
0
 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;
 }
コード例 #2
0
 public function getArrayCopy()
 {
     $data = parent::getArrayCopy();
     $data['adapter_name'] = $this->adapterName;
     $data['hydrator_name'] = $this->hydratorName;
     $data['table_name'] = $this->tableName;
     $data['table_service'] = $this->tableService;
     if (empty($data['service_name'])) {
         $data['service_name'] = $this->tableName;
     }
     return $data;
 }
コード例 #3
0
 /**
  * @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]);
 }
コード例 #4
0
 public function getArrayCopy()
 {
     $return = parent::getArrayCopy();
     $return['service_name'] = $this->serviceName;
     return $return;
 }
コード例 #5
0
 /**
  * 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]]);
     }
 }
コード例 #6
0
 /**
  * @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]);
     }
 }
コード例 #7
0
    /**
     * @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);
 }