Skip to content

Commit

Permalink
Fixed empty includes
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Aug 18, 2015
1 parent d6a9ac7 commit ec5c6d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#### Changed
- Improved and more extensive documentation

### 0.3.5 - 2015-08-19

#### Fixed
- The included key is not sent if it is empty

### 0.3.4 - 2015-08-18

#### Fixed
Expand Down
8 changes: 8 additions & 0 deletions src/JsonApi/Schema/Included.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class Included
*/
private $included = [];

/**
* @return bool
*/
public function isEmpty()
{
return empty($this->included);
}

/**
* @param array $transformedResource
* @return $this
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApi/Transformer/AbstractCompoundDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function transformContent(RequestInterface $request)
$content["data"] = $this->data;

// Included
if ($this->included !== null) {
if ($this->included->isEmpty() === false) {
$content["included"] = $this->included->transform();
}

Expand Down

0 comments on commit ec5c6d4

Please sign in to comment.