Skip to content

Commit

Permalink
Merge pull request #78 from svandervlugt/symf7
Browse files Browse the repository at this point in the history
[BC] Add Symfony 7 support and drop Symfony 5.4, replace annotations …
  • Loading branch information
svandervlugt authored May 13, 2024
2 parents 1b64284 + 626a2de commit a7da20a
Show file tree
Hide file tree
Showing 32 changed files with 55 additions and 1,155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['8.1', '8.2']
name: PHP ${{ matrix.php-versions }}
steps:
- uses: actions/checkout@v2
Expand Down
29 changes: 12 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,23 @@
"license": "MIT",
"minimum-stability": "stable",
"require": {
"php": "^7.3|^8.0",
"php": "^8.1",
"hostnet/form-handler-component": "^1.7.3",
"symfony/expression-language": "^4.0|^5.0|^6.0",
"symfony/http-foundation": "^4.0|^5.0|^6.0"
"symfony/expression-language": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0"
},
"require-dev": {
"doctrine/annotations": "^1.0",
"hostnet/phpcs-tool": "^9.1.0",
"phpunit/phpunit": "^9.5.5",
"sensio/framework-extra-bundle": "3.*|^5.0|^6.0",
"symfony/browser-kit": "^4.0|^5.0|^6.0",
"symfony/finder": "^4.0|^5.0|^6.0",
"symfony/form": "^4.0|^5.0|^6.0",
"symfony/framework-bundle": "^4.0|^5.0|^6.0",
"symfony/http-kernel": "^4.0|^5.0|^6.0",
"symfony/phpunit-bridge": "^2.8|^3.0|^4.0|^5.0|^6.0",
"symfony/translation": "^4.0|^5.0|^6.0",
"symfony/validator": "^4.0|^5.0|^6.0",
"symfony/yaml": "^4.0|^5.0|^6.0"
},
"suggest": {
"sensio/framework-extra-bundle": "To utilize form param converter."
"symfony/browser-kit": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0",
"symfony/form": "^6.4|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/translation": "^6.4|^7.0",
"symfony/validator": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0"
},
"autoload": {
"psr-4": {
Expand Down

This file was deleted.

32 changes: 0 additions & 32 deletions src/FormHandlerBundle.php

This file was deleted.

12 changes: 3 additions & 9 deletions src/HostnetFormHandlerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

namespace Hostnet\Bundle\FormHandlerBundle;

use Hostnet\Bundle\FormHandlerBundle\DependencyInjection\Compiler\FormHandlerRegistryCompilerPass;
use Hostnet\Component\Form\FormHandlerInterface;
use Hostnet\Component\FormHandler\HandlerTypeInterface;
use Symfony\Component\Config\FileLocator;
Expand All @@ -19,19 +18,14 @@ class HostnetFormHandlerBundle extends Bundle
/**
* @see \Symfony\Component\HttpKernel\Bundle\Bundle::build()
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
// load default services.yml
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/Resources/config'));
$loader->load('services.yaml');

parent::build($container);
$container->addCompilerPass(new FormHandlerRegistryCompilerPass());

// If auto configuring is available, register tags for the Handler Types.
if (method_exists($container, 'registerForAutoconfiguration')) {
$container->registerForAutoconfiguration(FormHandlerInterface::class)->addTag('form.handler');
$container->registerForAutoconfiguration(HandlerTypeInterface::class)->addTag('form.handler');
}
$container->registerForAutoconfiguration(FormHandlerInterface::class)->addTag('form.handler');
$container->registerForAutoconfiguration(HandlerTypeInterface::class)->addTag('form.handler');
}
}
101 changes: 0 additions & 101 deletions src/ParamConverter/FormParamConverter.php

This file was deleted.

13 changes: 6 additions & 7 deletions src/Registry/LegacyHandlerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Hostnet\Component\FormHandler\Exception\InvalidHandlerTypeException;
use Hostnet\Component\FormHandler\HandlerRegistryInterface;
use Hostnet\Component\FormHandler\HandlerTypeAdapter;
use Hostnet\Component\FormHandler\HandlerTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

final class LegacyHandlerRegistry implements HandlerRegistryInterface
Expand All @@ -20,11 +21,11 @@ final class LegacyHandlerRegistry implements HandlerRegistryInterface
private $container;

/**
* @var array[]
* @var HandlerTypeInterface[]
*/
private $handlers;
private iterable $handlers;

public function __construct(ContainerInterface $container, array $handlers)
public function __construct(ContainerInterface $container, iterable $handlers)
{
$this->handlers = $handlers;
$this->container = $container;
Expand All @@ -35,13 +36,11 @@ public function __construct(ContainerInterface $container, array $handlers)
*/
public function getType($class)
{
foreach ($this->handlers as list($service_id, $handler_class)) {
if ($handler_class !== $class) {
foreach ($this->handlers as $handler) {
if ($handler::class !== $class) {
continue;
}

$handler = $this->container->get($service_id);

if ($handler instanceof FormHandlerInterface) {
return new HandlerTypeAdapter($handler);
}
Expand Down
14 changes: 1 addition & 13 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
services:
form_handler.param_converter:
class: Hostnet\Bundle\FormHandlerBundle\ParamConverter\FormParamConverter
arguments:
- "@service_container"
- [] # inject from the compiler pass
tags:
- { name: request.param_converter, converter: form_information_converter }

form_handler.provider.simple:
class: Hostnet\Component\Form\Simple\SimpleFormProvider
arguments:
Expand All @@ -16,17 +8,13 @@ services:
class: Hostnet\Bundle\FormHandlerBundle\Registry\LegacyHandlerRegistry
arguments:
- "@service_container"
- [] # injected from the compiler pass
- !tagged_iterator form.handler

hostnet.form_handler.factory:
class: Hostnet\Component\FormHandler\HandlerFactory
arguments:
- "@form.factory"
- "@hostnet.form_handler.registry"

Hostnet\Bundle\FormHandlerBundle\ParamConverter\FormParamConverter: '@form_handler.param_converter'
Hostnet\Bundle\FormHandlerBundle\Registry\LegacyHandlerRegistry: '@hostnet.form_handler.registry'
Hostnet\Component\Form\FormProviderInterface: '@form_handler.provider.simple'
Hostnet\Component\Form\Simple\SimpleFormProvider: '@form_handler.provider.simple'
Hostnet\Component\FormHandler\HandlerFactory: '@hostnet.form_handler.factory'
Hostnet\Component\FormHandler\HandlerFactoryInterface: '@hostnet.form_handler.factory'
59 changes: 0 additions & 59 deletions test/DependencyInjection/FormHandlerRegistryCompilerPassTest.php

This file was deleted.

Loading

0 comments on commit a7da20a

Please sign in to comment.