|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
13 | 13 |
|
14 |
| -use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; |
15 |
| -use Symfony\Component\DependencyInjection\ContainerBuilder; |
16 |
| -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
17 |
| -use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; |
| 14 | +@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Component\Form\DependencyInjection\FormPass instead.', FormPass::class), E_USER_DEPRECATED); |
| 15 | + |
| 16 | +use Symfony\Component\Form\DependencyInjection\FormPass as BaseFormPass; |
18 | 17 |
|
19 | 18 | /**
|
20 | 19 | * Adds all services with the tags "form.type" and "form.type_guesser" as
|
21 | 20 | * arguments of the "form.extension" service.
|
22 | 21 | *
|
| 22 | + * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseFormPass} instead. |
| 23 | + * |
23 | 24 | * @author Bernhard Schussek <bschussek@gmail.com>
|
24 | 25 | */
|
25 |
| -class FormPass implements CompilerPassInterface |
| 26 | +class FormPass extends BaseFormPass |
26 | 27 | {
|
27 |
| - use PriorityTaggedServiceTrait; |
28 |
| - |
29 |
| - public function process(ContainerBuilder $container) |
30 |
| - { |
31 |
| - if (!$container->hasDefinition('form.extension')) { |
32 |
| - return; |
33 |
| - } |
34 |
| - |
35 |
| - $definition = $container->getDefinition('form.extension'); |
36 |
| - |
37 |
| - // Builds an array with fully-qualified type class names as keys and service IDs as values |
38 |
| - $types = array(); |
39 |
| - |
40 |
| - foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) { |
41 |
| - $serviceDefinition = $container->getDefinition($serviceId); |
42 |
| - if (!$serviceDefinition->isPublic()) { |
43 |
| - throw new InvalidArgumentException(sprintf('The service "%s" must be public as form types are lazy-loaded.', $serviceId)); |
44 |
| - } |
45 |
| - |
46 |
| - // Support type access by FQCN |
47 |
| - $types[$serviceDefinition->getClass()] = $serviceId; |
48 |
| - } |
49 |
| - |
50 |
| - $definition->replaceArgument(1, $types); |
51 |
| - |
52 |
| - $typeExtensions = array(); |
53 |
| - |
54 |
| - foreach ($this->findAndSortTaggedServices('form.type_extension', $container) as $reference) { |
55 |
| - $serviceId = (string) $reference; |
56 |
| - $serviceDefinition = $container->getDefinition($serviceId); |
57 |
| - if (!$serviceDefinition->isPublic()) { |
58 |
| - throw new InvalidArgumentException(sprintf('The service "%s" must be public as form type extensions are lazy-loaded.', $serviceId)); |
59 |
| - } |
60 |
| - |
61 |
| - $tag = $serviceDefinition->getTag('form.type_extension'); |
62 |
| - if (isset($tag[0]['extended_type'])) { |
63 |
| - $extendedType = $tag[0]['extended_type']; |
64 |
| - } else { |
65 |
| - throw new InvalidArgumentException(sprintf('Tagged form type extension must have the extended type configured using the extended_type/extended-type attribute, none was configured for the "%s" service.', $serviceId)); |
66 |
| - } |
67 |
| - |
68 |
| - $typeExtensions[$extendedType][] = $serviceId; |
69 |
| - } |
70 |
| - |
71 |
| - $definition->replaceArgument(2, $typeExtensions); |
72 |
| - |
73 |
| - // Find all services annotated with "form.type_guesser" |
74 |
| - $guessers = array_keys($container->findTaggedServiceIds('form.type_guesser')); |
75 |
| - foreach ($guessers as $serviceId) { |
76 |
| - $serviceDefinition = $container->getDefinition($serviceId); |
77 |
| - if (!$serviceDefinition->isPublic()) { |
78 |
| - throw new InvalidArgumentException(sprintf('The service "%s" must be public as form type guessers are lazy-loaded.', $serviceId)); |
79 |
| - } |
80 |
| - } |
81 |
| - |
82 |
| - $definition->replaceArgument(3, $guessers); |
83 |
| - } |
84 | 28 | }
|
0 commit comments