|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\DependencyInjection\Loader\Configurator; |
| 13 | + |
| 14 | +use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator; |
| 15 | +use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; |
| 16 | +use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator; |
| 17 | +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
| 18 | +use Symfony\Component\Form\Extension\Core\Type\ColorType; |
| 19 | +use Symfony\Component\Form\Extension\Core\Type\FileType; |
| 20 | +use Symfony\Component\Form\Extension\Core\Type\FormType; |
| 21 | +use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
| 22 | +use Symfony\Component\Form\Extension\Core\Type\TransformationFailureExtension; |
| 23 | +use Symfony\Component\Form\Extension\DependencyInjection\DependencyInjectionExtension; |
| 24 | +use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; |
| 25 | +use Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension; |
| 26 | +use Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension; |
| 27 | +use Symfony\Component\Form\Extension\Validator\Type\RepeatedTypeValidatorExtension; |
| 28 | +use Symfony\Component\Form\Extension\Validator\Type\SubmitTypeValidatorExtension; |
| 29 | +use Symfony\Component\Form\Extension\Validator\Type\UploadValidatorExtension; |
| 30 | +use Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser; |
| 31 | +use Symfony\Component\Form\FormFactory; |
| 32 | +use Symfony\Component\Form\FormFactoryInterface; |
| 33 | +use Symfony\Component\Form\FormRegistry; |
| 34 | +use Symfony\Component\Form\FormRegistryInterface; |
| 35 | +use Symfony\Component\Form\ResolvedFormTypeFactory; |
| 36 | +use Symfony\Component\Form\ResolvedFormTypeFactoryInterface; |
| 37 | +use Symfony\Component\Form\Util\ServerParams; |
| 38 | + |
| 39 | +return static function (ContainerConfigurator $container) { |
| 40 | + $container->services() |
| 41 | + ->set('form.resolved_type_factory', ResolvedFormTypeFactory::class) |
| 42 | + |
| 43 | + ->alias(ResolvedFormTypeFactoryInterface::class, 'form.resolved_type_factory') |
| 44 | + |
| 45 | + ->set('form.registry', FormRegistry::class) |
| 46 | + ->args([ |
| 47 | + [ |
| 48 | + /* |
| 49 | + * We don't need to be able to add more extensions. |
| 50 | + * more types can be registered with the form.type tag |
| 51 | + * more type extensions can be registered with the form.type_extension tag |
| 52 | + * more type_guessers can be registered with the form.type_guesser tag |
| 53 | + */ |
| 54 | + service('form.extension'), |
| 55 | + ], |
| 56 | + service('form.resolved_type_factory'), |
| 57 | + ]) |
| 58 | + |
| 59 | + ->alias(FormRegistryInterface::class, 'form.registry') |
| 60 | + |
| 61 | + ->set('form.factory', FormFactory::class) |
| 62 | + ->public() |
| 63 | + ->args([service('form.registry')]) |
| 64 | + |
| 65 | + ->alias(FormFactoryInterface::class, 'form.factory') |
| 66 | + |
| 67 | + ->set('form.extension', DependencyInjectionExtension::class) |
| 68 | + ->args([ |
| 69 | + abstract_arg('All services with tag "form.type" are stored in a service locator by FormPass'), |
| 70 | + abstract_arg('All services with tag "form.type_extension" are stored here by FormPass'), |
| 71 | + abstract_arg('All services with tag "form.type_guesser" are stored here by FormPass'), |
| 72 | + ]) |
| 73 | + |
| 74 | + ->set('form.type_guesser.validator', ValidatorTypeGuesser::class) |
| 75 | + ->args([service('validator.mapping.class_metadata_factory')]) |
| 76 | + ->tag('form.type_guesser') |
| 77 | + |
| 78 | + ->alias('form.property_accessor', 'property_accessor') |
| 79 | + |
| 80 | + ->set('form.choice_list_factory.default', DefaultChoiceListFactory::class) |
| 81 | + |
| 82 | + ->set('form.choice_list_factory.property_access', PropertyAccessDecorator::class) |
| 83 | + ->args([ |
| 84 | + service('form.choice_list_factory.default'), |
| 85 | + service('form.property_accessor'), |
| 86 | + ]) |
| 87 | + |
| 88 | + ->set('form.choice_list_factory.cached', CachingFactoryDecorator::class) |
| 89 | + ->args([service('form.choice_list_factory.property_access')]) |
| 90 | + ->tag('kernel.reset', ['method' => 'reset']) |
| 91 | + |
| 92 | + ->alias('form.choice_list_factory', 'form.choice_list_factory.cached') |
| 93 | + |
| 94 | + ->set('form.type.form', FormType::class) |
| 95 | + ->args([service('form.property_accessor')]) |
| 96 | + ->tag('form.type') |
| 97 | + |
| 98 | + ->set('form.type.choice', ChoiceType::class) |
| 99 | + ->args([service('form.choice_list_factory')]) |
| 100 | + ->tag('form.type') |
| 101 | + |
| 102 | + ->set('form.type.file', FileType::class) |
| 103 | + ->public() |
| 104 | + ->args([service('translator')->ignoreOnInvalid()]) |
| 105 | + ->tag('form.type') |
| 106 | + |
| 107 | + ->set('form.type.color', ColorType::class) |
| 108 | + ->args([service('translator')->ignoreOnInvalid()]) |
| 109 | + ->tag('form.type') |
| 110 | + |
| 111 | + ->set('form.type_extension.form.transformation_failure_handling', TransformationFailureExtension::class) |
| 112 | + ->args([service('translator')->ignoreOnInvalid()]) |
| 113 | + ->tag('form.type_extension', ['extended-type' => FormType::class]) |
| 114 | + |
| 115 | + ->set('form.type_extension.form.http_foundation', FormTypeHttpFoundationExtension::class) |
| 116 | + ->args([service('form.type_extension.form.request_handler')]) |
| 117 | + ->tag('form.type_extension') |
| 118 | + |
| 119 | + ->set('form.type_extension.form.request_handler', HttpFoundationRequestHandler::class) |
| 120 | + ->args([service('form.server_params')]) |
| 121 | + |
| 122 | + ->set('form.server_params', ServerParams::class) |
| 123 | + ->args([service('request_stack')]) |
| 124 | + |
| 125 | + ->set('form.type_extension.form.validator', FormTypeValidatorExtension::class) |
| 126 | + ->args([service('validator')]) |
| 127 | + ->tag('form.type_extension', ['extended-type' => FormType::class]) |
| 128 | + |
| 129 | + ->set('form.type_extension.repeated.validator', RepeatedTypeValidatorExtension::class) |
| 130 | + ->tag('form.type_extension') |
| 131 | + |
| 132 | + ->set('form.type_extension.submit.validator', SubmitTypeValidatorExtension::class) |
| 133 | + ->tag('form.type_extension', ['extended-type' => SubmitType::class]) |
| 134 | + |
| 135 | + ->set('form.type_extension.upload.validator', UploadValidatorExtension::class) |
| 136 | + ->args([ |
| 137 | + service('translator'), |
| 138 | + param('validator.translation_domain'), |
| 139 | + ]) |
| 140 | + ->tag('form.type_extension') |
| 141 | + ; |
| 142 | +}; |
0 commit comments