Skip to content

Commit 64921e6

Browse files
committed
Merge branch 'release/1.1.0' into main
2 parents b1d16f2 + 4effed7 commit 64921e6

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

CHANGELOG.md

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

6+
## [1.1.0] - 2022-01-03
7+
8+
### Fixed
9+
10+
- Fixed setting the top-level `jsonapi` value on the `Document` class, which was not setting the cast value.
11+
12+
### Removed
13+
14+
- The `RelationshipDocument` no longer merges relationship links with the top-level document links. This is because we
15+
now expect the top-level links provided to the encoder to already have the relationship links merged. The `core`
16+
package takes care of this in the relationship response classes, while also providing the capability for the developer
17+
to turn off link merging if desired (which is a better implementation). This change is considered non-breaking because
18+
the core package dependency has been upgraded and there were existing bugs in the links merging implementation within
19+
the `RelationshipDocument` class. I.e. it would fail if either of the self or related links were missing, or if the
20+
relationship was hidden - so removing this merging fixes bugs in the implementation.
21+
622
## [1.0.0] - 2021-07-31
723

824
Initial stable release, with no changes since `1.0.0-beta.1`.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"php": "^7.4|^8.0",
2727
"ext-json": "*",
2828
"illuminate/support": "^8.0",
29-
"laravel-json-api/core": "^1.0.0",
29+
"laravel-json-api/core": "^1.1",
3030
"laravel-json-api/neomerx-json-api": "^4.0.2"
3131
},
3232
"require-dev": {

src/Document.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
abstract class Document implements JsonApiDocument
2929
{
30-
3130
/**
3231
* @var ExtendedEncoder
3332
*/
@@ -81,7 +80,7 @@ abstract protected function encode(): string;
8180
public function withJsonApi($jsonApi): self
8281
{
8382
if ($value = JsonApi::nullable($jsonApi)) {
84-
$this->jsonApi = $jsonApi;
83+
$this->jsonApi = $value;
8584
}
8685

8786
return $this;
@@ -226,4 +225,12 @@ protected function encoder(): ExtendedEncoder
226225
{
227226
return $this->encoder;
228227
}
228+
229+
/**
230+
* @return Mapper
231+
*/
232+
protected function mapper(): Mapper
233+
{
234+
return $this->mapper;
235+
}
229236
}

src/RelationshipDocument.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@
2424

2525
class RelationshipDocument extends Document
2626
{
27-
2827
/**
2928
* @var JsonApiResource
3029
*/
31-
private JsonApiResource $resource;
30+
protected JsonApiResource $resource;
3231

3332
/**
3433
* @var string
3534
*/
36-
private string $fieldName;
35+
protected string $fieldName;
3736

3837
/**
3938
* @var mixed
4039
*/
41-
private $data;
40+
protected $data;
4241

4342
/**
4443
* RelationshipDocument constructor.
@@ -69,8 +68,6 @@ protected function serialize(): array
6968
{
7069
return $this
7170
->encoder()
72-
->withRelationshipSelfLink($this->resource, $this->fieldName)
73-
->withRelationshipRelatedLink($this->resource, $this->fieldName)
7471
->serializeIdentifiers($this->data);
7572
}
7673

@@ -81,9 +78,6 @@ protected function encode(): string
8178
{
8279
return $this
8380
->encoder()
84-
->withRelationshipSelfLink($this->resource, $this->fieldName)
85-
->withRelationshipRelatedLink($this->resource, $this->fieldName)
8681
->encodeIdentifiers($this->data);
8782
}
88-
8983
}

0 commit comments

Comments
 (0)