Skip to content

Commit 110ea47

Browse files
author
Lee Hicks
committed
Merge branch 'release/0.14.2'
2 parents 8ac4a28 + 33f9bcc commit 110ea47

7 files changed

Lines changed: 101 additions & 68 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [Unreleased]
6+
## [0.14.2] - 2018-02-25
7+
### Fixed
8+
- DF-1296 Allowed for wildcard handling in session permission checks
9+
- DF-1270 Use potentially modified request in response format handling
10+
611
## [0.14.1] - 2018-01-25
712
### Added
813
- DF-1275 Initial support for multi-column constraints
@@ -627,8 +632,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
627632
## 0.1.0 - 2015-10-24
628633
First official release working with the new [dreamfactory](https://github.com/dreamfactorysoftware/dreamfactory) project.
629634

630-
[Unreleased]: https://github.com/dreamfactorysoftware/df-core/compare/0.14.1...HEAD
631-
[0.14.1]: https://github.com/dreamfactorysoftware/df-core/compare/0.14.1...0.14.1
635+
[Unreleased]: https://github.com/dreamfactorysoftware/df-core/compare/0.14.2...HEAD
636+
[0.14.2]: https://github.com/dreamfactorysoftware/df-core/compare/0.14.1...0.14.2
637+
[0.14.1]: https://github.com/dreamfactorysoftware/df-core/compare/0.14.0...0.14.1
632638
[0.14.0]: https://github.com/dreamfactorysoftware/df-core/compare/0.13.1...0.14.0
633639
[0.13.1]: https://github.com/dreamfactorysoftware/df-core/compare/0.13.0...0.13.1
634640
[0.13.0]: https://github.com/dreamfactorysoftware/df-core/compare/0.12.3...0.13.0

database/migrations/2017_05_13_024529_system_config_update.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function up()
2323
if (Schema::hasColumn('system_config', 'db_version')) {
2424
Schema::table('system_config', function (Blueprint $t) use ($onDelete) {
2525
// delete the old stuff and create the new config
26+
$t->dropPrimary('system_config_db_version_primary');
2627
$t->dropColumn('db_version');
2728
$t->dropColumn('created_date');
2829
$t->dropColumn('last_modified_date');

src/Http/Controllers/RestController.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class RestController extends Controller
2626
* @param null|string $version
2727
*
2828
* @return null|ServiceResponseInterface|Response
29+
* @throws \DreamFactory\Core\Exceptions\NotImplementedException
2930
*/
3031
public function index($version = null)
3132
{
@@ -93,9 +94,9 @@ public function index($version = null)
9394
$response = ResponseFactory::create(['services' => $services, 'service_types' => $types]);
9495
Log::info('[RESPONSE]', ['Status Code' => $response->getStatusCode(), 'Content-Type' => $response->getContentType()]);
9596

96-
return ResponseFactory::sendResponse($response);
97+
return ResponseFactory::sendResponse($response, $request);
9798
} catch (\Exception $e) {
98-
return ResponseFactory::sendException($e);
99+
return ResponseFactory::sendException($e, (isset($request) ? $request : null));
99100
}
100101
}
101102

@@ -107,6 +108,7 @@ public function index($version = null)
107108
* @param null|string $resource
108109
*
109110
* @return ServiceResponseInterface|Response|null
111+
* @throws \DreamFactory\Core\Exceptions\NotImplementedException
110112
*/
111113
public function handleVersionedService($version, $service, $resource = null)
112114
{
@@ -123,6 +125,7 @@ public function handleVersionedService($version, $service, $resource = null)
123125
* @param null|string $resource
124126
*
125127
* @return ServiceResponseInterface|Response|null
128+
* @throws \DreamFactory\Core\Exceptions\NotImplementedException
126129
*/
127130
public function handleService($service, $resource = null)
128131
{
@@ -131,6 +134,13 @@ public function handleService($service, $resource = null)
131134
return $this->handleServiceRequest($request, $service, $resource);
132135
}
133136

137+
/**
138+
* @param ServiceRequest $request
139+
* @param $service
140+
* @param null $resource
141+
* @return array|ServiceResponseInterface|mixed|string|Response
142+
* @throws \DreamFactory\Core\Exceptions\NotImplementedException
143+
*/
134144
protected function handleServiceRequest(ServiceRequest $request, $service, $resource = null)
135145
{
136146
try {
@@ -151,9 +161,9 @@ protected function handleServiceRequest(ServiceRequest $request, $service, $reso
151161
return $response;
152162
}
153163

154-
return ResponseFactory::sendResponse($response, null, null, $resource);
164+
return ResponseFactory::sendResponse($response, $request, null, $resource);
155165
} catch (\Exception $e) {
156-
return ResponseFactory::sendException($e);
166+
return ResponseFactory::sendException($e, $request);
157167
}
158168
}
159169
}

src/Http/Middleware/AccessCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function handle($request, Closure $next)
104104
throw new ForbiddenException($msg);
105105
}
106106
} catch (\Exception $e) {
107-
return ResponseFactory::sendException($e, $request);
107+
return ResponseFactory::sendException($e);
108108
}
109109
}
110110
}

src/Http/Middleware/AuthCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function handle(Request $request, \Closure $next)
231231

232232
return $next($request);
233233
} catch (\Exception $e) {
234-
return ResponseFactory::sendException($e, $request);
234+
return ResponseFactory::sendException($e);
235235
}
236236
}
237237

src/Utility/ResponseFactory.php

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace DreamFactory\Core\Utility;
44

5-
use DreamFactory\Core\Components\ExceptionResponse;
6-
use DreamFactory\Core\Exceptions\BadRequestException;
7-
use DreamFactory\Core\Exceptions\RestException;
85
use DreamFactory\Core\Components\DfResponse;
6+
use DreamFactory\Core\Components\ExceptionResponse;
97
use DreamFactory\Core\Contracts\HttpStatusCodeInterface;
10-
use DreamFactory\Core\Enums\HttpStatusCodes;
8+
use DreamFactory\Core\Contracts\ServiceRequestInterface;
119
use DreamFactory\Core\Contracts\ServiceResponseInterface;
1210
use DreamFactory\Core\Enums\DataFormats;
11+
use DreamFactory\Core\Enums\HttpStatusCodes;
1312
use DreamFactory\Core\Exceptions\DfException;
13+
use DreamFactory\Core\Exceptions\RestException;
1414

1515
/**
1616
* Class ResponseFactory
@@ -52,24 +52,21 @@ public static function createExceptionFromResponse(ServiceResponseInterface $res
5252
}
5353

5454
/**
55-
* @param \DreamFactory\Core\Contracts\ServiceResponseInterface $response
56-
* @param null $accepts
57-
* @param null $asFile
58-
* @param string $resource
55+
* @param ServiceResponseInterface $response
56+
* @param ServiceRequestInterface|null $request
57+
* @param null $asFile
58+
* @param string $resource
5959
*
6060
* @return \Symfony\Component\HttpFoundation\Response
61-
* @throws \DreamFactory\Core\Exceptions\BadRequestException
6261
* @throws \DreamFactory\Core\Exceptions\NotImplementedException
6362
*/
6463
public static function sendResponse(
6564
ServiceResponseInterface $response,
66-
$accepts = null,
65+
ServiceRequestInterface $request = null,
6766
$asFile = null,
6867
$resource = 'resource'
6968
) {
70-
if (empty($accepts)) {
71-
$accepts = static::getAcceptedTypes();
72-
}
69+
$accepts = static::getAcceptedTypes($request);
7370

7471
if (empty($asFile)) {
7572
$asFile = \Request::input('file');
@@ -200,7 +197,6 @@ public static function sendResponse(
200197
* @param ServiceResponseInterface $response
201198
*
202199
* @return array|mixed|string
203-
* @throws BadRequestException
204200
*/
205201
public static function sendScriptResponse(ServiceResponseInterface $response)
206202
{
@@ -234,28 +230,31 @@ public static function sendScriptResponse(ServiceResponseInterface $response)
234230
}
235231

236232
/**
237-
* @param \Exception $e
238-
* @param \Illuminate\Http\Request $request
233+
* @param \Exception $e
234+
* @param ServiceRequestInterface $request
239235
*
240236
* @return array|mixed|string
237+
* @throws \DreamFactory\Core\Exceptions\NotImplementedException
241238
*/
242-
public static function sendException(
243-
\Exception $e,
244-
/** @noinspection PhpUnusedParameterInspection */
245-
$request = null
246-
) {
239+
public static function sendException(\Exception $e, ServiceRequestInterface $request = null)
240+
{
247241
$response = static::exceptionToServiceResponse($e);
248242

249-
return ResponseFactory::sendResponse($response);
243+
return ResponseFactory::sendResponse($response, $request);
250244
}
251245

252246
/**
253247
*
248+
* @param ServiceRequestInterface|null $request
254249
* @return array
255250
*/
256-
public static function getAcceptedTypes()
251+
public static function getAcceptedTypes(ServiceRequestInterface $request = null)
257252
{
258-
$accepts = \Request::query('accept', \Request::header('ACCEPT'));
253+
if ($request) {
254+
$accepts = $request->getParameter('accept', $request->getHeader('accept'));
255+
} else {
256+
$accepts = \Request::query('accept', \Request::header('accept'));
257+
}
259258
$accepts = array_map('trim', explode(',', $accepts));
260259

261260
return $accepts;

0 commit comments

Comments
 (0)