mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Fix BC Break in SelectAttributeChoicesCollectionType
This commit is contained in:
parent
f297799825
commit
a9546e0081
4 changed files with 26 additions and 5 deletions
|
|
@ -1,6 +1,8 @@
|
|||
# UPGRADE FROM `v1.12.9` TO `v1.12.10`
|
||||
|
||||
1. The `Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\SelectAttributeChoicesCollectionType` constructor has been removed as it is not used anymore.
|
||||
1. The `Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\SelectAttributeChoicesCollectionType` only
|
||||
constructor argument has been made optional and is `null` by default, subsequently the first argument of
|
||||
`sylius.form.type.attribute_type.select.choices_collection` has been removed.
|
||||
|
||||
# UPGRADE FROM `v1.12.8` TO `v1.12.9`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@managing_product_attributes
|
||||
Feature: Seeing correct select attribute values in different locale than default one
|
||||
In order to see correct attribute values in different locale than default one
|
||||
As and Administrator
|
||||
As an Administrator
|
||||
I should be able to create attribute with values in different locale than default one
|
||||
|
||||
Background:
|
||||
|
|
@ -16,4 +16,4 @@ Feature: Seeing correct select attribute values in different locale than default
|
|||
And I add value "Banana Skin" in "French (France)"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
And it should see value "Banana Skin"
|
||||
And I should see the value "Banana Skin"
|
||||
|
|
|
|||
|
|
@ -365,9 +365,9 @@ final class ManagingProductAttributesContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then /^it should see value "([^"]*)"/
|
||||
* @Then I should see the value :value
|
||||
*/
|
||||
public function theSelectAttributeShouldHaveValueInLocale(string $value): void
|
||||
public function iShouldSeeTheValue(string $value): void
|
||||
{
|
||||
Assert::true($this->updatePage->hasAttributeValue($value));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Sylius\Component\Resource\Translation\Provider\TranslationLocaleProviderInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -22,6 +23,15 @@ use Symfony\Component\Form\FormEvents;
|
|||
|
||||
class SelectAttributeChoicesCollectionType extends AbstractType
|
||||
{
|
||||
private ?string $defaultLocaleCode = null;
|
||||
|
||||
public function __construct(?TranslationLocaleProviderInterface $localeProvider = null)
|
||||
{
|
||||
if (null !== $localeProvider) {
|
||||
$this->defaultLocaleCode = $localeProvider->getDefaultLocaleCode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidScalarArgument Some weird magic going on here, not sure about refactor
|
||||
*/
|
||||
|
|
@ -40,6 +50,10 @@ class SelectAttributeChoicesCollectionType extends AbstractType
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($this->defaultLocaleCode !== null && !array_key_exists($this->defaultLocaleCode, $values)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = (string) $key;
|
||||
$newKey = $this->getUniqueKey();
|
||||
$fixedData[$newKey] = $this->resolveValues($values);
|
||||
|
|
@ -73,6 +87,11 @@ class SelectAttributeChoicesCollectionType extends AbstractType
|
|||
return Uuid::uuid1()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array-key, mixed|null> $values
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function resolveValues(array $values): array
|
||||
{
|
||||
$fixedValues = [];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue