Skip to content

Commit 6021e40

Browse files
committed
Remove wrong deprecation triggers for forms in the DI extension
When a form type provides a BC layer with old form names (all core types do), the form registry will ask for type extensions registered on the legacy name for BC, and trigger a warning if it finds any. The DependencyInjectionExtension should not trigger warnings on its own when being asked for such extensions (especially when it has none registered). Core extensions are also registered using the proper extended type rather than legacy names.
1 parent 3c0cfe0 commit 6021e40

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

Extension/DependencyInjection/DependencyInjectionExtension.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,17 @@ class DependencyInjectionExtension implements FormExtensionInterface
2222
private $typeServiceIds;
2323
private $typeExtensionServiceIds;
2424
private $guesserServiceIds;
25-
private $legacyNames;
2625
private $guesser;
2726
private $guesserLoaded = false;
2827

2928
public function __construct(ContainerInterface $container,
3029
array $typeServiceIds, array $typeExtensionServiceIds,
31-
array $guesserServiceIds, array $legacyNames = array())
30+
array $guesserServiceIds)
3231
{
3332
$this->container = $container;
3433
$this->typeServiceIds = $typeServiceIds;
3534
$this->typeExtensionServiceIds = $typeExtensionServiceIds;
3635
$this->guesserServiceIds = $guesserServiceIds;
37-
$this->legacyNames = $legacyNames;
3836
}
3937

4038
public function getType($name)
@@ -43,14 +41,10 @@ public function getType($name)
4341
throw new InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name));
4442
}
4543

46-
if (isset($this->legacyNames[$name])) {
47-
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
48-
}
49-
5044
$type = $this->container->get($this->typeServiceIds[$name]);
5145

5246
// BC: validate result of getName() for legacy names (non-FQCN)
53-
if (isset($this->legacyNames[$name]) && $type->getName() !== $name) {
47+
if ($name !== get_class($type) && $type->getName() !== $name) {
5448
throw new InvalidArgumentException(
5549
sprintf('The type name specified for the service "%s" does not match the actual name. Expected "%s", given "%s"',
5650
$this->typeServiceIds[$name],
@@ -65,23 +59,11 @@ public function getType($name)
6559

6660
public function hasType($name)
6761
{
68-
if (isset($this->typeServiceIds[$name])) {
69-
if (isset($this->legacyNames[$name])) {
70-
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
71-
}
72-
73-
return true;
74-
}
75-
76-
return false;
62+
return isset($this->typeServiceIds[$name]);
7763
}
7864

7965
public function getTypeExtensions($name)
8066
{
81-
if (isset($this->legacyNames[$name])) {
82-
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
83-
}
84-
8567
$extensions = array();
8668

8769
if (isset($this->typeExtensionServiceIds[$name])) {
@@ -95,10 +77,6 @@ public function getTypeExtensions($name)
9577

9678
public function hasTypeExtensions($name)
9779
{
98-
if (isset($this->legacyNames[$name])) {
99-
@trigger_error('Accessing form types by type name/service ID is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
100-
}
101-
10280
return isset($this->typeExtensionServiceIds[$name]);
10381
}
10482

0 commit comments

Comments
 (0)