Skip to content

Allow RelatedLink in Document. Fixes #104 #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.1.2] - 2020-03-16
### Fixed
- Related links must be allowed inside relationship documents (#104)

## [2.1.1] - 2019-12-19
### Fixed
- ResourceIdentifier does not allow multiple meta members (#99)
Expand All @@ -22,7 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- v2 initial release

[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.1...HEAD
[2.2.0]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.2...HEAD
[2.1.2]: https://github.com/json-api-php/json-api/compare/2.1.1...2.1.2
[2.1.1]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0
[2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"require": {
"php": ">=7.1",
"ext-json": "*"

},
"require-dev": {
"phpunit/phpunit": "^7.0||^8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Identifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
interface Identifier
{
/**
* @internal
* @param array $registry
* @internal
*/
public function registerIn(array &$registry): void;
}
3 changes: 2 additions & 1 deletion src/Link/RelatedLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
namespace JsonApiPhp\JsonApi\Link;

use function JsonApiPhp\JsonApi\child;
use JsonApiPhp\JsonApi\Internal\DataDocumentMember;
use JsonApiPhp\JsonApi\Internal\LinkTrait;
use JsonApiPhp\JsonApi\Internal\RelationshipMember;

final class RelatedLink implements RelationshipMember
final class RelatedLink implements RelationshipMember, DataDocumentMember
{
use LinkTrait;

Expand Down
2 changes: 1 addition & 1 deletion src/PaginatedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function attachTo($o): void
}

/**
* @internal
* @param array $registry
* @internal
*/
public function registerIn(array &$registry): void
{
Expand Down
27 changes: 13 additions & 14 deletions test/DataDocument/ManyResourceObjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use JsonApiPhp\JsonApi\Attribute;
use JsonApiPhp\JsonApi\DataDocument;
use JsonApiPhp\JsonApi\JsonApi;
use JsonApiPhp\JsonApi\Link\RelatedLink;
use JsonApiPhp\JsonApi\Link\SelfLink;
use JsonApiPhp\JsonApi\Meta;
use JsonApiPhp\JsonApi\ResourceCollection;
Expand Down Expand Up @@ -33,24 +34,23 @@ public function testExtendedDocument()
'
{
"data": [{
"type": "apples",
"type": "people",
"id": "1",
"attributes": {
"color": "red",
"sort": "Fuji"
"name": "Martin Fowler"
},
"meta": {"apple_meta": "foo"}
},{
"type": "apples",
"type": "people",
"id": "2",
"attributes": {
"color": "yellow",
"sort": "Gala"
"name": "Kent Beck"
},
"meta": {"apple_meta": "foo"}
}],
"links": {
"self": "/apples"
"self": "/books/123/relationships/authors",
"related": "/books/123/authors"
},
"jsonapi": {
"version": "1.0"
Expand All @@ -61,21 +61,20 @@ public function testExtendedDocument()
new DataDocument(
new ResourceCollection(
new ResourceObject(
'apples',
'people',
'1',
new Attribute('color', 'red'),
new Attribute('sort', 'Fuji'),
new Attribute('name', 'Martin Fowler'),
new Meta('apple_meta', 'foo')
),
new ResourceObject(
'apples',
'people',
'2',
new Attribute('color', 'yellow'),
new Attribute('sort', 'Gala'),
new Attribute('name', 'Kent Beck'),
new Meta('apple_meta', 'foo')
)
),
new SelfLink('/apples'),
new SelfLink('/books/123/relationships/authors'),
new RelatedLink('/books/123/authors'),
new JsonApi(),
new Meta('document_meta', 'bar')
)
Expand Down
15 changes: 9 additions & 6 deletions test/DataDocument/SingleResourceIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use JsonApiPhp\JsonApi\DataDocument;
use JsonApiPhp\JsonApi\JsonApi;
use JsonApiPhp\JsonApi\Link\RelatedLink;
use JsonApiPhp\JsonApi\Link\SelfLink;
use JsonApiPhp\JsonApi\Meta;
use JsonApiPhp\JsonApi\ResourceIdentifier;
Expand All @@ -17,13 +18,13 @@ public function testMinimalDocument()
'
{
"data": {
"type": "apples",
"type": "companies",
"id": "1"
}
}
',
new DataDocument(
new ResourceIdentifier('apples', '1')
new ResourceIdentifier('companies', '1')
)
);
}
Expand All @@ -34,15 +35,16 @@ public function testExtendedDocument()
'
{
"data": {
"type": "apples",
"type": "companies",
"id": "1",
"meta": {
"apple_meta": "foo",
"bar": [42]
}
},
"links": {
"self": "/apples/1"
"self": "/books/123/relationships/publisher",
"related": "/books/123/publisher"
},
"jsonapi": {
"version": "1.0"
Expand All @@ -52,12 +54,13 @@ public function testExtendedDocument()
',
new DataDocument(
new ResourceIdentifier(
'apples',
'companies',
'1',
new Meta('apple_meta', 'foo'),
new Meta('bar', [42])
),
new SelfLink('/apples/1'),
new SelfLink('/books/123/relationships/publisher'),
new RelatedLink('/books/123/publisher'),
new JsonApi(),
new Meta('document_meta', 'bar')
)
Expand Down