Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #289 from webimpress/hotfix/content-negotiation
Browse files Browse the repository at this point in the history
Fixed keys in content-negotiation Admin module
  • Loading branch information
michalbundyra committed Jan 17, 2018
2 parents 689a9aa + cce1e45 commit 4db0e82
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions config/admin.config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2013-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2013-2017 Zend Technologies USA Inc. (http://www.zend.com)
*/

namespace ZF\Apigility\Doctrine\Admin;
Expand Down Expand Up @@ -78,7 +78,7 @@
Controller\DoctrineRpcService::class => 'HalJson',
Controller\DoctrineMetadataService::class => 'HalJson',
],
'accept-whitelist' => [
'accept_whitelist' => [
Controller\DoctrineAutodiscovery::class => [
'application/json',
'application/*+json',
Expand All @@ -96,7 +96,7 @@
'application/*+json',
],
],
'content-type-whitelist' => [
'content_type_whitelist' => [
Controller\DoctrineAutodiscovery::class => [
'application/json',
'application/*+json',
Expand Down
22 changes: 11 additions & 11 deletions src/Admin/Model/DoctrineRestServiceModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2013-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2013-2017 Zend Technologies USA Inc. (http://www.zend.com)
*/

namespace ZF\Apigility\Doctrine\Admin\Model;
Expand Down Expand Up @@ -730,11 +730,11 @@ public function createContentNegotiationConfig(DoctrineRestServiceEntity $detail
];
$whitelist = $details->acceptWhitelist;
if (! empty($whitelist)) {
$config['accept-whitelist'] = [$controllerService => $whitelist];
$config['accept_whitelist'] = [$controllerService => $whitelist];
}
$whitelist = $details->contentTypeWhitelist;
if (! empty($whitelist)) {
$config['content-type-whitelist'] = [$controllerService => $whitelist];
$config['content_type_whitelist'] = [$controllerService => $whitelist];
}
$config = ['zf-content-negotiation' => $config];
$this->configResource->patch($config, true);
Expand Down Expand Up @@ -949,13 +949,13 @@ public function updateContentNegotiationConfig(

$acceptWhitelist = $update->acceptWhitelist;
if (is_array($acceptWhitelist) && $acceptWhitelist) {
$key = $baseKey . 'accept-whitelist.' . $service;
$key = $baseKey . 'accept_whitelist.' . $service;
$this->configResource->patchKey($key, $acceptWhitelist);
}

$contentTypeWhitelist = $update->contentTypeWhitelist;
if (is_array($contentTypeWhitelist) && $contentTypeWhitelist) {
$key = $baseKey . 'content-type-whitelist.' . $service;
$key = $baseKey . 'content_type_whitelist.' . $service;
$this->configResource->patchKey($key, $contentTypeWhitelist);
}
}
Expand Down Expand Up @@ -1041,10 +1041,10 @@ public function deleteDoctrineRestConfig(DoctrineRestServiceEntity $entity)
$key = ['zf-content-negotiation', 'controllers', $entity->controllerServiceName];
$this->configResource->deleteKey($key);

$key = ['zf-content-negotiation', 'accept-whitelist', $entity->controllerServiceName];
$key = ['zf-content-negotiation', 'accept_whitelist', $entity->controllerServiceName];
$this->configResource->deleteKey($key);

$key = ['zf-content-negotiation', 'content-type-whitelist', $entity->controllerServiceName];
$key = ['zf-content-negotiation', 'content_type_whitelist', $entity->controllerServiceName];
$this->configResource->deleteKey($key);

$key = ['zf-hal', 'metadata_map', $entity->collectionClass];
Expand Down Expand Up @@ -1210,15 +1210,15 @@ protected function mergeContentNegotiationConfig(
]);
}

if (isset($config['accept-whitelist'][$controllerServiceName])) {
if (isset($config['accept_whitelist'][$controllerServiceName])) {
$metadata->exchangeArray([
'accept_whitelist' => $config['accept-whitelist'][$controllerServiceName],
'accept_whitelist' => $config['accept_whitelist'][$controllerServiceName],
]);
}

if (isset($config['content-type-whitelist'][$controllerServiceName])) {
if (isset($config['content_type_whitelist'][$controllerServiceName])) {
$metadata->exchangeArray([
'content-type-whitelist' => $config['content-type-whitelist'][$controllerServiceName],
'content_type_whitelist' => $config['content_type_whitelist'][$controllerServiceName],
]);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Admin/Model/DoctrineRpcServiceModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2013-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2013-2017 Zend Technologies USA Inc. (http://www.zend.com)
*/

namespace ZF\Apigility\Doctrine\Admin\Model;
Expand Down Expand Up @@ -398,13 +398,13 @@ public function createContentNegotiationConfig($controllerService, $selector = n
'controllers' => [
$controllerService => $selector,
],
'accept-whitelist' => [
'accept_whitelist' => [
$controllerService => [
'application/json',
'application/*+json',
],
],
'content-type-whitelist' => [
'content_type_whitelist' => [
$controllerService => [
'application/json',
],
Expand Down Expand Up @@ -556,10 +556,10 @@ public function deleteContentNegotiationConfig($serviceName)
$key = ['zf-content-negotiation', 'controllers', $serviceName];
$this->configResource->deleteKey($key);

$key = ['zf-content-negotiation', 'accept-whitelist', $serviceName];
$key = ['zf-content-negotiation', 'accept_whitelist', $serviceName];
$this->configResource->deleteKey($key);

$key = ['zf-content-negotiation', 'content-type-whitelist', $serviceName];
$key = ['zf-content-negotiation', 'content_type_whitelist', $serviceName];
$this->configResource->deleteKey($key);
}

Expand Down

0 comments on commit 4db0e82

Please sign in to comment.