Skip to content

Commit bd2d19d

Browse files
authored
Merge pull request #5 from FastyBird/feature/hydrate-attributes
Allow to hydrate only attributes without relations
2 parents 63af331 + b133e3f commit bd2d19d

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/Hydrators/Hydrator.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function __construct(
161161
public function hydrate(
162162
JsonAPIDocument\IDocument $document,
163163
object|null $entity = null,
164+
bool $includeRelationShips = true,
164165
): Utils\ArrayHash
165166
{
166167
$entityMapping = $this->mapEntity($this->getEntityName());
@@ -186,12 +187,16 @@ public function hydrate(
186187
null,
187188
);
188189

189-
$relationships = $this->hydrateRelationships(
190-
$resource->getRelationships(),
191-
$entityMapping,
192-
$document->hasIncluded() ? $document->getIncluded() : null,
193-
$entity,
194-
);
190+
$relationships = [];
191+
192+
if ($includeRelationShips) {
193+
$relationships = $this->hydrateRelationships(
194+
$resource->getRelationships(),
195+
$entityMapping,
196+
$document->hasIncluded() ? $document->getIncluded() : null,
197+
$entity,
198+
);
199+
}
195200

196201
if ($this->errors->hasErrors()) {
197202
throw $this->errors;

0 commit comments

Comments
 (0)