Skip to content

Commit

Permalink
Drop Symfony 4.4 and Twig 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Apr 21, 2023
1 parent 1b90d99 commit 513ce7c
Show file tree
Hide file tree
Showing 41 changed files with 248 additions and 391 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ jobs:
dependencies: lowest
allowed-to-fail: false
variant: normal
- 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
58 changes: 29 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,34 @@
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"psr/log": "^2.0 || ^3.0",
"sonata-project/doctrine-extensions": "^1.13 || ^2.0",
"sonata-project/form-extensions": "^1.4",
"sonata-project/twig-extensions": "^1.3 || ^2.0",
"symfony/asset": "^4.4 || ^5.4 || ^6.2",
"symfony/config": "^4.4.11 || ^5.4 || ^6.2",
"symfony/console": "^4.4 || ^5.4 || ^6.2",
"symfony/dependency-injection": "^4.4.8 || ^5.4 || ^6.2",
"symfony/event-dispatcher": "^4.4 || ^5.4 || ^6.2",
"symfony/filesystem": "^4.4 || ^5.4 || ^6.2",
"symfony/finder": "^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-client": "^4.4.11 || ^5.4 || ^6.2",
"symfony/http-foundation": "^4.4 || ^5.4 || ^6.2",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.2",
"symfony/mime": "^4.4 || ^5.4 || ^6.2",
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.2",
"symfony/routing": "^4.4 || ^5.4 || ^6.2",
"symfony/security-bundle": "^4.4 || ^5.4 || ^6.2",
"symfony/security-core": "^4.4.24 || ^5.4 || ^6.2",
"symfony/translation": "^4.4 || ^5.4 || ^6.2",
"symfony/translation-contracts": "^1.1 || ^2.0 || ^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/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/event-dispatcher": "^5.4 || ^6.2",
"symfony/filesystem": "^5.4 || ^6.2",
"symfony/finder": "^5.4 || ^6.2",
"symfony/form": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.2",
"symfony/http-client": "^5.4 || ^6.2",
"symfony/http-foundation": "^5.4 || ^6.2",
"symfony/http-kernel": "^5.4 || ^6.2",
"symfony/mime": "^5.4 || ^6.2",
"symfony/options-resolver": "^5.4 || ^6.2",
"symfony/routing": "^5.4 || ^6.2",
"symfony/security-bundle": "^5.4 || ^6.2",
"symfony/security-core": "^5.4 || ^6.2",
"symfony/translation": "^5.4 || ^6.2",
"symfony/translation-contracts": "^2.0 || ^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.14 || ^3.0"
"twig/twig": "^3.0"
},
"require-dev": {
"async-aws/simple-s3": "^1.0",
Expand All @@ -83,17 +83,17 @@
"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",
"rector/rector": "^0.15",
"sonata-project/admin-bundle": "^4.9",
"sonata-project/block-bundle": "^4.11",
"sonata-project/classification-bundle": "^4.0",
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.2",
"symfony/messenger": "^4.4 || ^5.4 || ^6.2",
"symfony/browser-kit": "^5.4 || ^6.2",
"symfony/messenger": "^5.4 || ^6.2",
"symfony/phpunit-bridge": "^6.2",
"symfony/security-csrf": "^4.4 || ^5.4 || ^6.2",
"vimeo/psalm": "^4.7.2 || ^5.0"
"symfony/security-csrf": "^5.4 || ^6.2",
"vimeo/psalm": "^5.0"
},
"conflict": {
"async-aws/simple-s3": "<1.0",
Expand Down
12 changes: 3 additions & 9 deletions src/Admin/BaseMediaAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ protected function configurePersistentParameters(): array
}

$request = $this->getRequest();
$filter = $request->query->all('filter');

// TODO: Change to $request->query->all('filter') when support for Symfony < 5.1 is dropped.
$filter = $request->query->all()['filter'] ?? [];

if (\is_array($filter) && \array_key_exists('context', $filter)) {
if (\array_key_exists('context', $filter)) {
$context = $filter['context']['value'];
} else {
$context = $request->query->get('context', $this->pool->getDefaultContext());
Expand Down Expand Up @@ -162,11 +160,7 @@ protected function alterNewInstance(object $object): void
if ($request->isMethod('POST')) {
$uniqId = $this->getUniqId();

// TODO: Change to $request->request->all($uniqid)['providerName'] when support for Symfony < 5.1 is dropped.
$data = $request->request->all()[$uniqId] ?? [];
\assert(\is_array($data));

$providerName = $data['providerName'];
$providerName = $request->request->all($uniqId)['providerName'];
} else {
$providerName = $request->query->get('provider');
}
Expand Down
8 changes: 0 additions & 8 deletions src/Command/AddMassMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#[AsCommand(name: 'sonata:media:add-multiple', description: 'Add medias in mass into the database')]
final class AddMassMediaCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:add-multiple';
protected static $defaultDescription = 'Add medias in mass into the database';

/**
* @var string[]
*/
Expand All @@ -43,11 +39,7 @@ public function __construct(private MediaManagerInterface $mediaManager)

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addOption('file', null, InputOption::VALUE_REQUIRED, 'The file to parse')
->addOption('delimiter', null, InputOption::VALUE_REQUIRED, 'Set the field delimiter (one character only)', ',')
->addOption('enclosure', null, InputOption::VALUE_REQUIRED, 'Set the field enclosure character (one character only).', '"')
Expand Down
8 changes: 0 additions & 8 deletions src/Command/AddMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#[AsCommand(name: 'sonata:media:add', description: 'Add a media into the database')]
final class AddMediaCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:add';
protected static $defaultDescription = 'Add a media into the database';

/**
* @internal This class should only be used through the console
*/
Expand All @@ -38,11 +34,7 @@ public function __construct(private MediaManagerInterface $mediaManager)

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addArgument('providerName', InputArgument::REQUIRED, 'The provider')
->addArgument('context', InputArgument::REQUIRED, 'The context')
->addArgument('binaryContent', InputArgument::REQUIRED, 'The content')
Expand Down
8 changes: 0 additions & 8 deletions src/Command/CleanMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
#[AsCommand(name: 'sonata:media:clean-uploads', description: 'Find orphaned files in media upload directory')]
final class CleanMediaCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:clean-uploads';
protected static $defaultDescription = 'Find orphaned files in media upload directory';

/**
* @var string[]|null
*/
Expand All @@ -51,11 +47,7 @@ public function __construct(

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Execute the cleanup as a dry run. This doesn\'t remove any files');
}

Expand Down
12 changes: 0 additions & 12 deletions src/Command/FixMediaContextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#[AsCommand(name: 'sonata:media:fix-media-context', description: 'Generate the default category for each media context')]
final class FixMediaContextCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:fix-media-context';
protected static $defaultDescription = 'Generate the default category for each media context';

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

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

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

protected function execute(InputInterface $input, OutputInterface $output): int
{
if (null === $this->categoryManager || null === $this->contextManager) {
Expand Down
8 changes: 0 additions & 8 deletions src/Command/RefreshMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#[AsCommand(name: 'sonata:media:refresh-metadata', description: 'Refresh meta information')]
final class RefreshMetadataCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:refresh-metadata';
protected static $defaultDescription = 'Refresh meta information';

private bool $quiet = false;

/**
Expand All @@ -49,11 +45,7 @@ public function __construct(

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addArgument('providerName', InputArgument::OPTIONAL, 'The provider')
->addArgument('context', InputArgument::OPTIONAL, 'The context');
}
Expand Down
8 changes: 0 additions & 8 deletions src/Command/RemoveThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#[AsCommand(name: 'sonata:media:remove-thumbnails', description: 'Remove uploaded image thumbs')]
final class RemoveThumbsCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:remove-thumbnails';
protected static $defaultDescription = 'Remove uploaded image thumbs';

private bool $quiet = false;

/**
Expand All @@ -51,11 +47,7 @@ public function __construct(

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addArgument('providerName', InputArgument::OPTIONAL, 'The provider')
->addArgument('context', InputArgument::OPTIONAL, 'The context')
->addArgument('format', InputArgument::OPTIONAL, 'The format (pass `all` to delete all thumbs)')
Expand Down
8 changes: 0 additions & 8 deletions src/Command/SyncThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
#[AsCommand(name: 'sonata:media:sync-thumbnails', description: 'Sync uploaded image thumbs with new media formats')]
final class SyncThumbsCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:sync-thumbnails';
protected static $defaultDescription = 'Sync uploaded image thumbs with new media formats';

private bool $quiet = false;

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

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addArgument('providerName', InputArgument::OPTIONAL, 'The provider')
->addArgument('context', InputArgument::OPTIONAL, 'The context')
->addOption('batchSize', null, InputOption::VALUE_REQUIRED, 'Media batch size (100 by default)', '100')
Expand Down
8 changes: 0 additions & 8 deletions src/Command/UpdateCdnStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
#[AsCommand(name: 'sonata:media:update-cdn-status', description: 'Updates model media with the current CDN status')]
final class UpdateCdnStatusCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 5.4 is dropped.
protected static $defaultName = 'sonata:media:update-cdn-status';
protected static $defaultDescription = 'Updates model media with the current CDN status';

private bool $quiet = false;

/**
Expand All @@ -51,11 +47,7 @@ public function __construct(

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

$this
// TODO: Remove setDescription when support for Symfony < 5.4 is dropped.
->setDescription(static::$defaultDescription)
->addArgument('providerName', InputArgument::OPTIONAL, 'The provider')
->addArgument('context', InputArgument::OPTIONAL, 'The context')
->setHelp(
Expand Down
5 changes: 2 additions & 3 deletions src/Controller/MediaAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ public function listAction(Request $request): Response

$datagrid = $this->admin->getDatagrid();

// TODO: Change to $request->query->all('filter') when support for Symfony < 5.1 is dropped.
$filters = $request->query->all()['filter'] ?? [];
$filters = $request->query->all('filter');

// set the default context
if (\is_array($filters) && \array_key_exists('context', $filters)) {
if (\array_key_exists('context', $filters)) {
$context = $filters['context']['value'];
} else {
$pool = $this->container->get('sonata.media.pool');
Expand Down
9 changes: 4 additions & 5 deletions src/Resources/config/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Sonata\MediaBundle\Action\MediaDownloadAction;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
$containerConfigurator->services()

->set('sonata.media.action.media_download', MediaDownloadAction::class)
->public()
->args([
new ReferenceConfigurator('sonata.media.manager.media'),
new ReferenceConfigurator('sonata.media.pool'),
service('sonata.media.manager.media'),
service('sonata.media.pool'),
]);
};
Loading

0 comments on commit 513ce7c

Please sign in to comment.