-
-
Notifications
You must be signed in to change notification settings - Fork 907
Make Max Depth work with HAL #1971
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
Conversation
{ | ||
if ( | ||
!isset($context[static::ENABLE_MAX_DEPTH]) || | ||
!isset($attributesMetadata[$attribute]) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add $context[static::ENABLE_MAX_DEPTH ||
now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, although there will now be a behavioral difference between hal and the other formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until symfony/symfony#27365 is merged
don't merge. there is a bug here. |
@dunglas this is done. I can't see how the failure is due to this PR |
|
||
public function testMaxDepth() | ||
{ | ||
$setId = function (MaxDepthDummy $dummy, int $id): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void
isn't supported in PHP 7.0. It's why Travis is red.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed that, but there is a strange random behat failure.
@dunglas yep, random behat scenario passing on travis but failing on circleci. |
It's not random, it uses an outdated version of the scenario: https://github.com/api-platform/core/blob/master/features/jsonld/context.feature#L21 |
done, but i'm still not sure how it passed on travis and failed on circle 😆 |
Because Travis takes |
very good! |
private function isMaxDepthReached(array $attributesMetadata, string $class, string $attribute, array &$context): bool | ||
{ | ||
if ( | ||
!isset($context[static::ENABLE_MAX_DEPTH]) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be ($context[static::ENABLE_MAX_DEPTH] ?? false)
(not possible in Symfony because we still support PHP 5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost, it's !($context[static::ENABLE_MAX_DEPTH] ?? false)
.
done
Thanks @bendavies! |
Using
@MaxDepth
does not work with hal+json.This is because relations are normalized separately from the parent:
https://github.com/api-platform/core/blob/master/src/Hal/Serializer/ItemNormalizer.php#L55-L63
so the context of max depth isn't checked.