Skip to content
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

Use ArrayAccess interface instead of Doctrine Collection #7539

Closed
wants to merge 2 commits into from

Conversation

TheFox
Copy link

@TheFox TheFox commented Oct 15, 2021

Subject

I am targeting this branch, because it's a fix for version 3.

Closes #7538.

Changelog

### Changed

- Instead of using the Collection interface an easy switch to ArrayAccess interface can be used.

Fixes sonata-project#7538.

Instead of using the Collection interface an easy switch to ArrayAccess interface can be used.
@TheFox TheFox changed the title Use ArrayAccess interface instead of Doctrine Collection. Use ArrayAccess interface instead of Doctrine Collection Oct 15, 2021
Check if it's ArrayAccess or array.
Fixes sonata-project#7538.
Copy link
Member

@VincentLanglet VincentLanglet left a comment

Choose a reason for hiding this comment

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

Does a unit test would be possible ?

@@ -240,10 +240,10 @@ public function appendFormFieldElement(AdminInterface $admin, $subject, $element

$collection = $this->propertyAccessor->getValue($subject, $path);

if (!($collection instanceof Collection)) {
if (!($collection instanceof \ArrayAccess) && !is_array($collection)) {
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 the () around instanceof are unnecesary.

@TheFox
Copy link
Author

TheFox commented Oct 15, 2021

I just realized that this would not fix the other issue in #7538. It's also about Nested Collections. When I add a nested collection in level 2 I get this error:

Could not get element id from s61695531a2b2e_questions_1_answers Failing part: answers

@VincentLanglet
Copy link
Member

Hi, can you rebase ?

@jordisala1991
Copy link
Member

I found one case where we use this strategy too, so this Pr makes sense to me. (the case is located at the appenParentObject of the on AbstractAdmin)

@VincentLanglet
Copy link
Member

Do you have the time to finish the PR @TheFox ? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants