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

IBX-8980: Fixed getGroupedFields method implementation #77

Open
wants to merge 8 commits into
base: 4.6
Choose a base branch
from

Conversation

Sztig
Copy link

@Sztig Sztig commented Nov 21, 2024

🎫 Issue IBX-8980

Related PRs:

Description:

Based on the interface of GroupedContentFormFieldsProvider the method getGroupedFields is implemented incorrectly. The description of the interface states Array of fieldGroupIdentifier grouped by fieldGroupName should be returned. Right now it doesn't return the fieldGroupIdentifier but a translation of said identifier.

For the example the previously retrieved key would be Basic Information, after the fix it's going to be basic_information

@Sztig Sztig requested a review from a team November 21, 2024 11:07
$groupedFields = [];

foreach ($fieldsDataForm as $fieldForm) {
/** @var \Ibexa\Contracts\ContentForms\Data\Content\FieldData $fieldData */
$fieldData = $fieldForm->getViewData();
$fieldGroupIdentifier = $this->fieldsGroupsList->getFieldGroup($fieldData->fieldDefinition);
$fieldGroupName = $fieldsGroups[$fieldGroupIdentifier] ?? $this->fieldsGroupsList->getDefaultGroup();
Copy link
Contributor

Choose a reason for hiding this comment

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

Even tho it seems like a bug, not sure we can fix it that way due to bc policy. Otoh, this seems so internal and if only used by that one place (is it tho?) it should be acceptable.
@ibexa/php-dev

@ViniTou ViniTou requested a review from a team December 9, 2024 11:37
Copy link
Contributor

@mikadamczyk mikadamczyk left a comment

Choose a reason for hiding this comment

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

It seems that $fieldGroupName which is a key in the returned array is used in other places (admin-ui, product-catalog).

@Sztig
Copy link
Author

Sztig commented Jan 14, 2025

Alright, I will try then implementing a new provider and update the templates in corporate-account to use said provider instead.

@Sztig Sztig force-pushed the IBX-8980-grouped-fields-fix branch from 81aef34 to d53ab22 Compare January 20, 2025 13:44
Comment on lines 18 to 19
/** @var \Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList */
private $fieldsGroupsList;
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer typed properties over annotations, when dealing with PHP 7.4+ and no BC.

Suggested change
/** @var \Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList */
private $fieldsGroupsList;
private FieldsGroupsList $fieldsGroupsList;

]);

$subject = new GroupedContentFormFieldsProvider($fieldsGroupsListMock);
$subject = new NonLocalizedGroupedContentFormFieldsProvider($fieldsGroupsListMock);
Copy link
Contributor

Choose a reason for hiding this comment

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

This - given it's a separate class - should be in it's own test case/class. Currently you're replacing a test for existing class with this one.

Copy link
Author

Choose a reason for hiding this comment

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

👍 I will make a new class for tests for the new provider and revert the old test as they were.

@adamwojs adamwojs requested a review from a team February 2, 2025 11:28
@@ -13,6 +13,9 @@
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;

/**
* @deprecated since 4.6.17 this class is deprecated. Please use NonLocalizedGroupedContentFormFieldsProvider instead
Copy link
Contributor

Choose a reason for hiding this comment

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

FQCN could be used here

@Sztig Sztig requested a review from a team February 4, 2025 15:21
Copy link

sonarqubecloud bot commented Feb 4, 2025

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.

4 participants