Skip to content

Commit

Permalink
Drop Symfony 4 and Twig 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Apr 19, 2023
1 parent 0b440fc commit 6dfa064
Show file tree
Hide file tree
Showing 36 changed files with 289 additions and 553 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ jobs:
dependencies: highest
allowed-to-fail: false
variant: sonata-project/form-extensions:"2.x-dev as 1.999"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
symfony-require: 4.4.*
variant: symfony/symfony:"4.4.*"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
Expand Down
64 changes: 32 additions & 32 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,40 @@
"knplabs/knp-menu": "^3.1",
"knplabs/knp-menu-bundle": "^3.0",
"psr/container": "^1.0 || ^2.0",
"psr/log": "^1.1 || ^2.0 || ^3.0",
"psr/log": "^2.0 || ^3.0",
"sonata-project/block-bundle": "^4.11",
"sonata-project/doctrine-extensions": "^1.8 || ^2.0",
"sonata-project/exporter": "^2.14 || ^3.1.1",
"sonata-project/form-extensions": "^1.15",
"sonata-project/twig-extensions": "^1.4.1 || ^2.0",
"symfony/asset": "^4.4 || ^5.4 || ^6.2",
"symfony/config": "^4.4 || ^5.4 || ^6.2",
"symfony/console": "^4.4 || ^5.4 || ^6.2",
"symfony/dependency-injection": "^4.4.8 || ^5.4 || ^6.2",
"symfony/doctrine-bridge": "^4.4 || ^5.4 || ^6.2",
"symfony/event-dispatcher": "^4.4 || ^5.4 || ^6.2",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0 || ^3.0",
"symfony/expression-language": "^4.4 || ^5.4 || ^6.2",
"symfony/form": "^4.4.12 || ^5.4 || ^6.2",
"symfony/framework-bundle": "^4.4.6 || ^5.4 || ^6.2",
"symfony/http-foundation": "^4.4 || ^5.4 || ^6.2",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.2",
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.2",
"symfony/property-access": "^4.4 || ^5.4 || ^6.2",
"symfony/routing": "^4.4 || ^5.4 || ^6.2",
"symfony/asset": "^5.4 || ^6.2",
"symfony/config": "^5.4 || ^6.2",
"symfony/console": "^5.4 || ^6.2",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/doctrine-bridge": "^5.4 || ^6.2",
"symfony/event-dispatcher": "^5.4 || ^6.2",
"symfony/event-dispatcher-contracts": "^2.0 || ^3.0",
"symfony/expression-language": "^5.4 || ^6.2",
"symfony/form": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/options-resolver": "^5.4 || ^6.2",
"symfony/property-access": "^5.4 || ^6.2",
"symfony/routing": "^5.4 || ^6.2",
"symfony/security-acl": "^3.1",
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.2",
"symfony/security-core": "^4.4.24 || ^5.4 || ^6.2",
"symfony/security-csrf": "^4.4 || ^5.4 || ^6.2",
"symfony/serializer": "^4.4 || ^5.4 || ^6.2",
"symfony/security-bundle": "^5.4 || ^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"symfony/security-csrf": "^5.4 || ^6.2",
"symfony/serializer": "^5.4 || ^6.2",
"symfony/string": "^5.4 || ^6.2",
"symfony/translation": "^4.4 || ^5.4 || ^6.2",
"symfony/translation-contracts": "^1.1.10 || ^2.3 || ^3.0",
"symfony/twig-bridge": "^4.4 || ^5.4 || ^6.2",
"symfony/twig-bundle": "^4.4 || ^5.4 || ^6.2",
"symfony/validator": "^4.4 || ^5.4 || ^6.2",
"symfony/translation": "^5.4 || ^6.2",
"symfony/translation-contracts": "^2.3 || ^3.0",
"symfony/twig-bridge": "^5.4 || ^6.2",
"symfony/twig-bundle": "^5.4 || ^6.2",
"symfony/validator": "^5.4 || ^6.2",
"twig/string-extra": "^3.0",
"twig/twig": "^2.12.1 || ^3.0"
"twig/twig": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
Expand All @@ -77,16 +77,16 @@
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-symfony": "^4.0 || ^5.0",
"psalm/plugin-symfony": "^5.0",
"psr/event-dispatcher": "^1.0",
"rector/rector": "^0.15",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.2",
"symfony/css-selector": "^4.4 || ^5.4 || ^6.2",
"symfony/filesystem": "^4.4 || ^5.4 || ^6.2",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/css-selector": "^5.4 || ^6.2",
"symfony/filesystem": "^5.4 || ^6.2",
"symfony/maker-bundle": "^1.25",
"symfony/phpunit-bridge": "^6.2",
"symfony/yaml": "^4.4 || ^5.4 || ^6.2",
"vimeo/psalm": "^4.9.2 || ^5.8.0"
"symfony/yaml": "^5.4 || ^6.2",
"vimeo/psalm": "^5.8.0"
},
"suggest": {
"twig/extra-bundle": "Auto configures the Twig Intl extension"
Expand Down
19 changes: 2 additions & 17 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\PropertyAccess\Exception\AccessException;
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface as RoutingUrlGeneratorInterface;
Expand Down Expand Up @@ -455,15 +452,8 @@ final public function getFilterParameters(): array

// build the values array
if ($this->hasRequest()) {
/** @var InputBag|ParameterBag $bag */
$bag = $this->getRequest()->query;
if ($bag instanceof InputBag) {
// symfony 5.1+
$filters = $bag->all('filter');
} else {
$filters = $bag->get('filter', []);
\assert(\is_array($filters));
}
$filters = $bag->all('filter');

if (isset($filters[DatagridInterface::PAGE])) {
$filters[DatagridInterface::PAGE] = (int) $filters[DatagridInterface::PAGE];
Expand Down Expand Up @@ -2277,12 +2267,7 @@ final protected function appendParentObject(object $object): void

try {
$value = $propertyAccessor->getValue($object, $parentAssociationMapping);
} catch (AccessException $e) {
// @todo: Catching and checking AccessException here as BC for symfony/property-access < 5.1.
// Catch UninitializedPropertyException and remove the check when dropping support < 5.1
if (AccessException::class !== $e::class && !$e instanceof UninitializedPropertyException) {
throw $e; // Re-throw. We only want to "ignore" pure AccessException (Sf < 5.1) and UninitializedPropertyException (Sf >= 5.1)
}
} catch (UninitializedPropertyException $e) {
$value = null;
}

Expand Down
65 changes: 0 additions & 65 deletions src/BCLayer/BCDeprecation.php

This file was deleted.

39 changes: 0 additions & 39 deletions src/BCLayer/BCUserInterface.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Command/ExplainAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#[AsCommand(name: 'sonata:admin:explain', description: 'Explain an admin service')]
final class ExplainAdminCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:admin:explain';
protected static $defaultDescription = 'Explain an admin service';

/**
* @internal This class should only be used through the console
*/
Expand All @@ -41,11 +37,7 @@ public function __construct(

public function configure(): void
{
\assert(null !== static::$defaultDescription);

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addArgument('admin', InputArgument::REQUIRED, 'The admin service id');
}

Expand Down
8 changes: 0 additions & 8 deletions src/Command/GenerateObjectAclCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
#[AsCommand(name: 'sonata:admin:generate-object-acl', description: 'Install ACL for the objects of the Admin Classes.')]
final class GenerateObjectAclCommand extends QuestionableCommand
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:admin:generate-object-acl';
protected static $defaultDescription = 'Install ACL for the objects of the Admin Classes.';

private string $userModelClass = '';

/**
Expand All @@ -48,11 +44,7 @@ public function __construct(

public function configure(): void
{
\assert(null !== static::$defaultDescription);

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addOption('object_owner', null, InputOption::VALUE_OPTIONAL, 'If set, the task will set the object owner for each admin.')
->addOption('user_model', null, InputOption::VALUE_OPTIONAL, 'Fully qualified class name <comment>App\Model\User</comment>. If not set, it will be asked the first time an object owner is set.')
->addOption('step', null, InputOption::VALUE_NONE, 'If set, the task will ask for each admin if the ACLs need to be generated and what object owner to set, if any.');
Expand Down
13 changes: 0 additions & 13 deletions src/Command/ListAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#[AsCommand(name: 'sonata:admin:list', description: 'List all admin services available')]
final class ListAdminCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:admin:list';
protected static $defaultDescription = 'List all admin services available';

/**
* @internal This class should only be used through the console
*/
Expand All @@ -38,15 +34,6 @@ public function __construct(
parent::__construct();
}

public function configure(): void
{
\assert(null !== static::$defaultDescription);

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription);
}

public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Admin services:</info>');
Expand Down
13 changes: 0 additions & 13 deletions src/Command/SetupAclCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#[AsCommand(name: 'sonata:admin:setup-acl', description: 'Install ACL for Admin Classes')]
final class SetupAclCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:admin:setup-acl';
protected static $defaultDescription = 'Install ACL for Admin Classes';

/**
* @internal This class should only be used through the console
*/
Expand All @@ -40,15 +36,6 @@ public function __construct(
parent::__construct();
}

public function configure(): void
{
\assert(null !== static::$defaultDescription);

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription);
}

public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Starting ACL AdminBundle configuration');
Expand Down
10 changes: 1 addition & 9 deletions src/Controller/CRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -408,14 +406,8 @@ public function batchAction(Request $request): Response

if (null === $encodedData) {
$action = $forwardedRequest->request->get('action');
/** @var InputBag|ParameterBag $bag */
$bag = $request->request;
if ($bag instanceof InputBag) {
// symfony 5.1+
$idx = $bag->all('idx');
} else {
$idx = (array) $bag->get('idx', []);
}
$idx = $bag->all('idx');
$allElements = $forwardedRequest->request->getBoolean('all_elements');

$forwardedRequest->request->set('idx', $idx);
Expand Down
Loading

0 comments on commit 6dfa064

Please sign in to comment.