Skip to content

Commit

Permalink
fix: correctly remove self link when it is false (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
saddamshahzadnxb authored Jan 11, 2025
1 parent 86e9dba commit 8eb7a37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/basics/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ class Schema extends SchemaProvider
{
// ...

public function getResourceLinks($resource): ?array
public function getResourceLinks($resource): iterable
{
return null;
return ['self' => false];
}
}
```
Expand Down
4 changes: 4 additions & 0 deletions src/Schema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ public function getLinks($resource): iterable
$links[LinkInterface::SELF] = $this->getSelfLink($resource);
}

if ($self === false) {
unset($links[LinkInterface::SELF]);
}

return $links;
}

Expand Down

0 comments on commit 8eb7a37

Please sign in to comment.