Skip to content

Commit 05a0846

Browse files
author
Robin Chalas
committed
Merge branch '4.2'
* 4.2: Ensure final input of CommandTester works with default Do not risk waiting 100 seconds [Intl] handle null date and time types Revert "minor #28610 [Form] Check for Intl availibility (ro0NL)" Do not ignore the choice groups for caching
2 parents b841ea8 + 2f54cb8 commit 05a0846

File tree

6 files changed

+12
-56
lines changed

6 files changed

+12
-56
lines changed

ChoiceList/Factory/CachingFactoryDecorator.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,6 @@ public static function generateHash($value, $namespace = '')
6262
return hash('sha256', $namespace.':'.serialize($value));
6363
}
6464

65-
/**
66-
* Flattens an array into the given output variable.
67-
*
68-
* @param array $array The array to flatten
69-
* @param array $output The flattened output
70-
*
71-
* @internal
72-
*/
73-
private static function flatten(array $array, &$output)
74-
{
75-
if (null === $output) {
76-
$output = array();
77-
}
78-
79-
foreach ($array as $key => $value) {
80-
if (\is_array($value)) {
81-
self::flatten($value, $output);
82-
continue;
83-
}
84-
85-
$output[$key] = $value;
86-
}
87-
}
88-
8965
public function __construct(ChoiceListFactoryInterface $decoratedFactory)
9066
{
9167
$this->decoratedFactory = $decoratedFactory;
@@ -113,12 +89,7 @@ public function createListFromChoices($choices, $value = null)
11389
// The value is not validated on purpose. The decorated factory may
11490
// decide which values to accept and which not.
11591

116-
// We ignore the choice groups for caching. If two choice lists are
117-
// requested with the same choices, but a different grouping, the same
118-
// choice list is returned.
119-
self::flatten($choices, $flatChoices);
120-
121-
$hash = self::generateHash(array($flatChoices, $value), 'fromChoices');
92+
$hash = self::generateHash(array($choices, $value), 'fromChoices');
12293

12394
if (!isset($this->lists[$hash])) {
12495
$this->lists[$hash] = $this->decoratedFactory->createListFromChoices($choices, $value);

Extension/Core/Type/CountryType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

Extension/Core/Type/CurrencyType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

Extension/Core/Type/LanguageType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

Extension/Core/Type/LocaleType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18-
use Symfony\Component\Form\Exception\LogicException;
1918
use Symfony\Component\Intl\Intl;
2019
use Symfony\Component\OptionsResolver\Options;
2120
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -42,10 +41,6 @@ public function configureOptions(OptionsResolver $resolver)
4241
{
4342
$resolver->setDefaults(array(
4443
'choice_loader' => function (Options $options) {
45-
if (!class_exists(Intl::class)) {
46-
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47-
}
48-
4944
$choiceTranslationLocale = $options['choice_translation_locale'];
5045

5146
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,24 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
6464
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
6565
}
6666

67-
public function testCreateFromChoicesFlattensChoices()
67+
public function testCreateFromChoicesGroupedChoices()
6868
{
6969
$choices1 = array('key' => array('A' => 'a'));
7070
$choices2 = array('A' => 'a');
71-
$list = new \stdClass();
71+
$list1 = new \stdClass();
72+
$list2 = new \stdClass();
7273

73-
$this->decoratedFactory->expects($this->once())
74+
$this->decoratedFactory->expects($this->at(0))
7475
->method('createListFromChoices')
7576
->with($choices1)
76-
->will($this->returnValue($list));
77+
->will($this->returnValue($list1));
78+
$this->decoratedFactory->expects($this->at(1))
79+
->method('createListFromChoices')
80+
->with($choices2)
81+
->will($this->returnValue($list2));
7782

78-
$this->assertSame($list, $this->factory->createListFromChoices($choices1));
79-
$this->assertSame($list, $this->factory->createListFromChoices($choices2));
83+
$this->assertSame($list1, $this->factory->createListFromChoices($choices1));
84+
$this->assertSame($list2, $this->factory->createListFromChoices($choices2));
8085
}
8186

8287
/**

0 commit comments

Comments
 (0)