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; }
/** * Create a new REST service * * @param array|object $data * @return RestServiceEntity * @throws CreationException */ public function create($data) { if (is_object($data)) { $data = (array) $data; } $type = RestServiceModelFactory::TYPE_DEFAULT; if (isset($data['table_name'])) { $creationData = new DbConnectedRestServiceEntity(); $type = RestServiceModelFactory::TYPE_DB_CONNECTED; } else { $creationData = new NewRestServiceEntity(); } $creationData->exchangeArray($data); $model = $this->getModel($type); try { $service = $model->createService($creationData); } catch (\Exception $e) { return new ApiProblem(409, sprintf("Unable to create REST service: %s", $e->getMessage())); } return $service; }
/** * @see https://github.com/zfcampus/zf-apigility-admin/issues/49 * @expectedException ZF\Apigility\Admin\Exception\RuntimeException */ public function testUpdateServiceWithUrlAlreadyExist() { $details = $this->getCreationPayload(); $original = $this->codeRest->createService($details); // Create a new REST entity $payload = $details->getArrayCopy(); $payload['service_name'] = 'bar'; $payload['route_match'] = '/api/bar'; $payload['route_identifier_name'] = 'bar_id'; $payload['collection_name'] = 'bar'; $restService = new NewRestServiceEntity(); $restService->exchangeArray($payload); $second = $this->codeRest->createService($restService); $payload = $second->getArrayCopy(); // Update the second REST service with same URL of the first one $payload['route_match'] = '/api/foo'; $patch = new NewRestServiceEntity(); $patch->exchangeArray($payload); $this->codeRest->updateService($patch); }
public function testCreateServiceUsesDefaultContentNegotiation() { $payload = new NewRestServiceEntity(); $payload->exchangeArray(array('service_name' => 'foo')); $result = $this->codeRest->createService($payload); $this->assertInstanceOf('ZF\\Apigility\\Admin\\Model\\RestServiceEntity', $result); $this->assertEquals(array('application/vnd.bar-conf.v1+json', 'application/hal+json', 'application/json'), $result->acceptWhitelist); $this->assertEquals(array('application/vnd.bar-conf.v1+json', 'application/json'), $result->contentTypeWhitelist); }