Skip to content

Commit 28e27fc

Browse files
committed
Merge branch 'release/0.6.0'
2 parents 24a9832 + 70c5a24 commit 28e27fc

7 files changed

+77
-18
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[*.{php,stub}]
10+
[*.{php,stub,json}]
1111
indent_size = 4
1212

1313
[*.md]

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
All notable changes to this project will be documented in this file. This project adheres to
33
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
44

5+
## [0.6.0] - 2017-02-20
6+
7+
### Added
8+
- Added support for Laravel 5.4. However, consuming applications will need to use the Browserkit testing package
9+
to continue to use the JSON API testing suite.
10+
11+
### Removed
12+
- Dropped support for PHP 5.5
13+
514
## [0.5.4] - 2016-12-21
615

716
### Fixed

UPGRADE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
This file provides notes on how to upgrade between versions.
44

5+
## v0.5 to v0.6
6+
7+
### Config
8+
9+
Add the following to your `json-api-errors.php` config file:
10+
11+
```php
12+
/**
13+
* When the resource type of a related resource is not recognised.
14+
*/
15+
V::RELATIONSHIP_UNKNOWN_TYPE => [
16+
Error::TITLE => 'Invalid Relationship',
17+
Error::DETAIL => "Resource type '{actual}' is not recognised.",
18+
Error::STATUS => 400,
19+
],
20+
```
21+
22+
### Other
23+
24+
This upgrade includes updating `cloudcreativity/json-api` from v0.6 to v0.7. This will not affect the vast majority
25+
of applications. However, if you have implemented your own Store or Validator Error Factory, you will need to refer
26+
to the upgrade notes in that package.
27+
528
## v0.5.0|v0.5.1 to v0.5.2
629

730
Version `0.5.2` adds generator commands to your application. We've updated the configuration so you will need to

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=5.5.0",
26-
"laravel/framework": "5.1.*|5.2.*|5.3.*",
27-
"neomerx/json-api": "^0.8.9",
28-
"cloudcreativity/json-api": "^0.6.0",
29-
"symfony/psr-http-message-bridge": "^0.2.0|^1.0",
25+
"php": "^5.6|^7.0",
26+
"laravel/framework": "5.1.*|5.2.*|5.3.*|5.4.*",
27+
"cloudcreativity/json-api": "^0.7",
28+
"symfony/psr-http-message-bridge": "^1.0",
3029
"zendframework/zend-diactoros": "^1.3"
3130
},
3231
"require-dev": {
33-
"phpunit/phpunit": "^4.7"
32+
"phpunit/phpunit": "^5.7"
3433
},
35-
"minimum-stability": "stable",
34+
"minimum-stability": "dev",
35+
"prefer-stable": true,
3636
"autoload": {
3737
"psr-4": {
3838
"CloudCreativity\\LaravelJsonApi\\": "src/"
@@ -44,8 +44,8 @@
4444
}
4545
},
4646
"extra": {
47-
"branch-alias": {
48-
"dev-develop": "0.6.x-dev"
49-
}
47+
"branch-alias": {
48+
"dev-develop": "0.6.x-dev"
49+
}
5050
}
5151
}

config/json-api-errors.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@
122122
Error::STATUS => 422,
123123
],
124124

125+
/**
126+
* When the resource type of a related resource is not recognised.
127+
*/
128+
V::RELATIONSHIP_UNKNOWN_TYPE => [
129+
Error::TITLE => 'Invalid Relationship',
130+
Error::DETAIL => "Resource type '{actual}' is not recognised.",
131+
Error::STATUS => 400,
132+
],
133+
125134
/**
126135
* When a related resource is not of the correct type for the relationship.
127136
*/

src/Schema/CreatesEloquentIdentities.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ protected function createBelongsToIdentity(Model $model, $relationshipKey)
6060
}
6161

6262
$related = $relation->getRelated()->replicate();
63-
$related->{$relation->getOtherKey()} = $id;
63+
64+
/** Laravel 5.4 */
65+
if (method_exists($relation, 'getOwnerKey')) {
66+
$related->{$relation->getOwnerKey()} = $id;
67+
} /** Laravel 5.1|5.2|5.3 */
68+
else {
69+
$related->{$relation->getOtherKey()} = $id;
70+
}
6471

6572
return $related;
6673
}

src/ServiceProvider.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,15 @@ protected function bootPublishing()
158158
*/
159159
protected function bootMiddleware(Router $router)
160160
{
161-
$router->middleware('json-api', BootJsonApi::class);
162-
$router->middleware('json-api.request', HandleRequest::class);
161+
/** Laravel 5.4 */
162+
if (method_exists($router, 'aliasMiddleware')) {
163+
$router->aliasMiddleware('json-api', BootJsonApi::class);
164+
$router->aliasMiddleware('json-api.request', HandleRequest::class);
165+
} /** Laravel 5.1|5.2|5.3 */
166+
else {
167+
$router->middleware('json-api', BootJsonApi::class);
168+
$router->middleware('json-api.request', HandleRequest::class);
169+
}
163170
}
164171

165172
/**
@@ -282,29 +289,32 @@ protected function bindErrorRepository()
282289
{
283290
$this->app->singleton(ReplacerInterface::class, Replacer::class);
284291

285-
$this->app->singleton(['json-api.errors' => ErrorRepositoryInterface::class], function () {
292+
$this->app->singleton(ErrorRepositoryInterface::class, function () {
286293
/** @var ReplacerInterface $replacer */
287294
$replacer = $this->app->make(ReplacerInterface::class);
288295
$repository = new ErrorRepository($replacer);
289296
$repository->configure($this->getErrorConfig());
290297
return $repository;
291298
});
299+
$this->app->alias(ErrorRepositoryInterface::class, 'json-api.errors');
292300
}
293301

294302
/**
295303
* Bind the exception parser into the service container.
296304
*/
297305
protected function bindExceptionParser()
298306
{
299-
$this->app->singleton(['json-api.exceptions' => ExceptionParserInterface::class], ExceptionParser::class);
307+
$this->app->singleton(ExceptionParserInterface::class, ExceptionParser::class);
308+
$this->app->alias(ExceptionParserInterface::class, 'json-api.exceptions');
300309
}
301310

302311
/**
303312
* Bind the store into the service container.
304313
*/
305314
protected function bindStore()
306315
{
307-
$this->app->singleton(['json-api.store' => StoreInterface::class], Store::class);
316+
$this->app->singleton(StoreInterface::class, Store::class);
317+
$this->app->alias(StoreInterface::class, 'json-api.store');
308318
}
309319

310320
/**
@@ -341,7 +351,8 @@ protected function bindStoreAdapters()
341351
*/
342352
protected function bindLinkFactory()
343353
{
344-
$this->app->singleton(['json-api.links' => LinkFactoryInterface::class], LinkFactory::class);
354+
$this->app->singleton(LinkFactoryInterface::class, LinkFactory::class);
355+
$this->app->alias(LinkFactoryInterface::class, 'json-api.links');
345356
}
346357

347358
/**

0 commit comments

Comments
 (0)