diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 100d783..2f54ccb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,18 +66,27 @@ jobs: - php-version: '8.2' composer-options: '--prefer-stable' symfony-version: '7.3.*' + - php-version: '8.2' + composer-options: '--prefer-stable' + symfony-version: '7.4.*' - php-version: '8.3' composer-options: '--prefer-stable' symfony-version: '6.4.*' - php-version: '8.3' composer-options: '--prefer-stable' symfony-version: '7.3.*' + - php-version: '8.3' + composer-options: '--prefer-stable' + symfony-version: '7.4.*' - php-version: '8.4' composer-options: '--prefer-stable' symfony-version: '6.4.*' - php-version: '8.4' composer-options: '--prefer-stable' symfony-version: '7.3.*' + - php-version: '8.4' + composer-options: '--prefer-stable' + symfony-version: '7.4.*' steps: - name: 'Check out' diff --git a/src/Qossmic/DependencyInjection/RichModelFormsExtension.php b/src/Qossmic/DependencyInjection/RichModelFormsExtension.php index 626d150..ccece21 100644 --- a/src/Qossmic/DependencyInjection/RichModelFormsExtension.php +++ b/src/Qossmic/DependencyInjection/RichModelFormsExtension.php @@ -18,7 +18,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; /** * @author Christian Flothmann @@ -29,7 +29,7 @@ final class RichModelFormsExtension extends Extension { public function load(array $configs, ContainerBuilder $container): void { - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.php'); } } diff --git a/src/Qossmic/Resources/config/services.php b/src/Qossmic/Resources/config/services.php new file mode 100644 index 0000000..241d0a8 --- /dev/null +++ b/src/Qossmic/Resources/config/services.php @@ -0,0 +1,54 @@ + + * (c) Christopher Hertel + * (c) QOSSMIC GmbH + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types = 1); + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Qossmic\RichModelForms\ExceptionHandling\ArgumentTypeMismatchExceptionHandler; +use Qossmic\RichModelForms\ExceptionHandling\ExceptionHandlerRegistry; +use Qossmic\RichModelForms\ExceptionHandling\FallbackExceptionHandler; +use Qossmic\RichModelForms\ExceptionHandling\FormExceptionHandler; +use Qossmic\RichModelForms\Extension\RichModelFormsTypeExtension; +use Symfony\Component\Form\Extension\Core\Type\FormType; + +return static function (ContainerConfigurator $container): void { + $container->services() + ->set('qossmic.rich_model_forms.type_extension', RichModelFormsTypeExtension::class) + ->args([ + service('property_accessor'), + service('qossmic.rich_model_forms.exception_handler.registry'), + service('qossmic.rich_model_forms.form_exception_handler'), + ]) + ->tag('form.type_extension', ['extended_type' => FormType::class]) + + ->set('qossmic.rich_model_forms.form_exception_handler', FormExceptionHandler::class) + ->args([ + service('qossmic.rich_model_forms.exception_handler.registry'), + service('translator')->ignoreOnInvalid(), + '%validator.translation_domain%', + ]) + + ->set('qossmic.rich_model_forms.exception_handler.registry', ExceptionHandlerRegistry::class) + ->args([ + abstract_arg('service locator'), + abstract_arg('exception handling strategies'), + ]) + + ->set('qossmic.rich_model_forms.exception_handler.strategy.argument_type_mismatch', ArgumentTypeMismatchExceptionHandler::class) + ->tag('qossmic.rich_model_forms.exception_handler', ['strategy' => 'type_error']) + + ->set('qossmic.rich_model_forms.exception_handler.strategy.fallback', FallbackExceptionHandler::class) + ->tag('qossmic.rich_model_forms.exception_handler', ['strategy' => 'fallback']) + ; +}; diff --git a/src/Qossmic/Resources/config/services.xml b/src/Qossmic/Resources/config/services.xml deleted file mode 100644 index e1c9f20..0000000 --- a/src/Qossmic/Resources/config/services.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - %validator.translation_domain% - - - - null - - - - - - - - - - - -