-
-
Notifications
You must be signed in to change notification settings - Fork 910
Subresource maxDepth #1520
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
Subresource maxDepth #1520
Conversation
Hey @soyuka, I tried to create a clean PR and rebase with |
e1418f2
to
2f34b3e
Compare
2f34b3e
to
a9e9a70
Compare
a9e9a70
to
4f46fe7
Compare
4f46fe7
to
4fe81e4
Compare
Arrgh I fixed it, why did you push again? ^^ To take the correct version don't use
(assuming your remote is named |
4fe81e4
to
21229f8
Compare
humm, I think it's Gitkraken... It makes automatic git pull when I load the project... I'm sorry |
I think its ok now 😅 |
@Nightbr no problem haha, FYI |
@@ -82,7 +82,8 @@ private function updateMetadata(ApiSubresource $annotation, PropertyMetadata $pr | |||
$type = $propertyMetadata->getType(); | |||
$isCollection = $type->isCollection(); | |||
$resourceClass = $isCollection ? $type->getCollectionValueType()->getClassName() : $type->getClassName(); | |||
$maxDepth = $annotation->maxDepth ? $annotation->maxDepth : null; |
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.
Do we really want to turn 0
into null
?
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.
depth 0 has no sens I think. If it's 0 or null, we do not apply maxDepth. If maxDepth=1 we create one subresource operation, if maxDepth=2 we create two subresources 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.
null is correct here yes
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.
Right, the behavior should be the same but IMO we should not transform the configured value: 0
is not null
(it's important in terms of extension point). What do you think about keeping 0
? The behavior will remain the same with your condition in SubresourceOperationFactory::computeSubresourceOperations()
.
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.
Good point! fixed
} | ||
|
||
if (null !== $maxDepth && $depth >= $maxDepth) { | ||
continue; |
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.
Should not it be break
here?
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.
👍
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! ty
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.
Nice improvement! Just a minor change to do in a docblock, then LGTM.
@@ -54,4 +56,12 @@ public function withCollection(bool $collection): self | |||
|
|||
return $metadata; | |||
} | |||
|
|||
/** | |||
* @return int |
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.
@return int|null
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!
@@ -82,7 +82,8 @@ private function updateMetadata(ApiSubresource $annotation, PropertyMetadata $pr | |||
$type = $propertyMetadata->getType(); | |||
$isCollection = $type->isCollection(); | |||
$resourceClass = $isCollection ? $type->getCollectionValueType()->getClassName() : $type->getClassName(); | |||
$maxDepth = $annotation->maxDepth; |
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.
Shouldn't we check that maxDepth
is int
here?
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.
Doctrine Annotation will handle that because of the PHPDoc IIRC.
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.
01944f3
to
03439d4
Compare
Thanks @Nightbr ! |
Thanks for your help! |
Subresource maxDepth
Proper PR from original: #1512