8000 [Form] fixes according to comments. · symfony/symfony@0753fcd · GitHub
[go: up one dir, main page]

Skip to content

Commit 0753fcd

Browse files
author
Hugo Hamon
committed
[Form] fixes according to comments.
1 parent 7367511 commit 0753fcd

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/Symfony/Component/Form/DependencyInjection/FormPass.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,20 @@ private function processFormTypeExtensions(ContainerBuilder $container)
8888
throw new InvalidArgumentException(sprintf('"%s" tagged services must have the extended type configured using the extended_type/extended-type attribute, none was configured for the "%s" service.', $this->formTypeExtensionTag, $serviceId));
8989
}
9090

91-
$typeExtensions[$extendedType][] = $serviceId;
91+
$typeExtensions[$extendedType][] = new Reference($serviceId);
9292
}
9393

94-
$allExtensions = array();
9594
foreach ($typeExtensions as $extendedType => $extensions) {
96-
$allExtensions[$extendedType] = new IteratorArgument(array_map(
97-
function ($extensionId) {
98-
return new Reference($extensionId);
99-
},
100-
$extensions
101-
));
95+
$typeExtensions[$extendedType] = new IteratorArgument($typeExtensions[$extendedType]);
10296
}
10397

104-
return $allExtensions;
98+
return $typeExtensions;
10599
}
106100

107101
private function processFormTypeGuessers(ContainerBuilder $container)
108102
{
109103
$guessers = array();
110-
foreach (array_keys($container->findTaggedServiceIds($this->formTypeGuesserTag)) as $serviceId) {
104+
foreach ($container->findTaggedServiceIds($this->formTypeGuesserTag) as $serviceId => $tags) {
111105
$guessers[] = new Reference($serviceId);
112106
}
113107

src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DependencyInjectionExtension implements FormExtensionInterface
3131
*
3232
* @param ContainerInterface $typeContainer
3333
* @param iterable[] $typeExtensionServices
34-
* @param array|\Traversable $guesserServices
34+
* @param iterable $guesserServices
3535
*/
3636
public function __construct(ContainerInterface $typeContainer, array $typeExtensionServices, $guesserServices, array $guesserServiceIds = null)
3737
{
@@ -48,6 +48,7 @@ public function __construct(ContainerInterface $typeContainer, array $typeExtens
4848

4949
public function getType($name)
5050
{
51+
// BC - this "if" block must be removed in Symfony 4.0
5152
if (null !== $this->guesserServiceIds) {
5253
if (!isset($this->typeServiceIds[$name])) {
5354
throw new InvalidArgumentException(sprintf('The field type "%s" is not registered in the service container.', $name));
@@ -65,6 +66,7 @@ public function getType($name)
6566

6667
public function hasType($name)
6768
{
69+
// BC - this "if" block must be removed in Symfony 4.0
6870
if (null !== $this->guesserServiceIds) {
6971
return isset($this->typeServiceIds[$name]);
7072
}
@@ -78,6 +80,7 @@ public function getTypeExtensions($name)
7880

7981
if (isset($this->typeExtensionServices[$name])) {
8082
foreach ($this->typeExtensionServices[$name] as $extensionId => $extension) {
83+
// BC - this "if" block must be removed in Symfony 4.0
8184
if (is_string($extension)) {
8285
$extensionId = $extension;
8386
$extension = $this->typeContainer->get($extension);
@@ -113,6 +116,7 @@ public function getTypeGuesser()
113116
$guessers = array();
114117

115118
8000 foreach ($this->guesserServices as $serviceId => $service) {
119+
// BC - this "if" block must be removed in Symfony 4.0
116120
if (is_string($service)) {
117121
$serviceId = $service;
118122
$service = $this->typeContainer->get($serviceId);

src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1616
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
17-
use Symfony\Component\DependencyInjection\Reference;
1817
use Symfony\Component\Form\DependencyInjection\FormPass;
1918
use Symfony\Component\DependencyInjection\ContainerBuilder;
2019
use Symfony\Component\DependencyInjection\Definition;
20+
use Symfony\Component\DependencyInjection\Reference;
2121
use Symfony\Component\Form\AbstractType;
2222

2323
/**

0 commit comments

Comments
 (0)
0