Skip to content

Conversation

guilliamxavier
Copy link
Contributor

@guilliamxavier guilliamxavier commented Jun 23, 2021

Q A
Branch? main
Tickets related to #4182 (comment)
License MIT
Doc PR

The initial implementation was wrong to pass the collection $propertyMetadata for each nested field, so I fixed it to use a new PropertyMetadata (empty, for lack of anything better)

}

$restriction['properties'][$field] = $this->mergeConstraintRestrictions($baseConstraint, $propertyMetadata);
$restriction['properties'][$field] = $this->mergeConstraintRestrictions($baseConstraint, new PropertyMetadata());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: ideally we would extract the nested field type from the Collection property metadata, but I don't know how to do that 😕

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure to understand this change, could you explain what it does please?

Copy link
Contributor Author

@guilliamxavier guilliamxavier Jun 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$propertyMetadata corresponds to the Collection property, but $baseConstraint corresponds to the nested $field.
Related: second commit of the referenced PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand but why using a parameter then? Because we need to "hydrate" the property metadata with the nested field type?

Copy link
Contributor Author

@guilliamxavier guilliamxavier Jun 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we could remove the 2nd parameter of

private function mergeConstraintRestrictions(Constraint $constraint, PropertyMetadata $propertyMetadata): array
but we would still need to have one anyway for
if ($restrictionMetadata->supports($nestedConstraint, $propertyMetadata) && !empty($nestedConstraintRestriction = $restrictionMetadata->create($nestedConstraint, $propertyMetadata))) {

And I was hoping one could eventually find a way to deduce a $fieldPropertyMetadata (at least a $fieldType for new PropertyMetadata($fieldType)) from $propertyMetadata+$field and/or $baseConstraint

(For the record: in my project I'm going to replace the Collection-annotated array with a true class subobject)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Update: the PR was missing a description, fixed now)

@soyuka
Copy link
Member

soyuka commented Aug 10, 2021

I like this could you rebase plesae?

@guilliamxavier
Copy link
Contributor Author

@soyuka: Sorry for the delay. Now rebased and updated. Thanks

@stale
Copy link

stale bot commented Nov 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 4, 2022
@stale
Copy link

stale bot commented Jan 3, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 3, 2023
@stale stale bot closed this Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants