Skip to content

Commit

Permalink
Fix deprecations for commands while maintian lazyness (#2314)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 authored Jun 25, 2022
1 parent 19f702f commit b1161c4
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"psalm/plugin-phpunit": "^0.16",
"psalm/plugin-symfony": "^3.0",
"sonata-project/admin-bundle": "^4.9",
"sonata-project/block-bundle": "^4.0",
"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.0",
Expand All @@ -100,7 +100,7 @@
"knplabs/knp-menu-bundle": "<3.0",
"liip/imagine-bundle": "<2.0",
"sonata-project/admin-bundle": "<4.9",
"sonata-project/block-bundle": "<4.0",
"sonata-project/block-bundle": "<4.11",
"sonata-project/classification-bundle": "<4.0",
"sonata-project/doctrine-orm-admin-bundle": "<4.0"
},
Expand Down
4 changes: 4 additions & 0 deletions src/Command/AddMassMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@

use Sonata\Doctrine\Model\ClearableManagerInterface;
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[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 < 6.0 is dropped.
protected static $defaultName = 'sonata:media:add-multiple';
protected static $defaultDescription = 'Add medias in mass into the database';

Expand All @@ -47,6 +50,7 @@ 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)', ',')
Expand Down
4 changes: 4 additions & 0 deletions src/Command/AddMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
namespace Sonata\MediaBundle\Command;

use Sonata\MediaBundle\Model\MediaManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[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 < 6.0 is dropped.
protected static $defaultName = 'sonata:media:add';
protected static $defaultDescription = 'Add a media into the database';

Expand All @@ -42,6 +45,7 @@ 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')
Expand Down
4 changes: 4 additions & 0 deletions src/Command/CleanMediaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\FileProvider;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -25,8 +26,10 @@
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

#[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 < 6.0 is dropped.
protected static $defaultName = 'sonata:media:clean-uploads';
protected static $defaultDescription = 'Find orphaned files in media upload directory';

Expand Down Expand Up @@ -58,6 +61,7 @@ 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
4 changes: 4 additions & 0 deletions src/Command/FixMediaContextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
use Sonata\ClassificationBundle\Model\CategoryManagerInterface;
use Sonata\ClassificationBundle\Model\ContextManagerInterface;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[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 < 6.0 is dropped.
protected static $defaultName = 'sonata:media:fix-media-context';
protected static $defaultDescription = 'Generate the default category for each media context';

Expand All @@ -47,6 +50,7 @@ protected function configure(): void
{
\assert(null !== static::$defaultDescription);

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

Expand Down
4 changes: 4 additions & 0 deletions src/Command/RefreshMetadataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -28,8 +29,10 @@
*
* Useful if you have existing media content and added new formats.
*/
#[AsCommand(name: 'sonata:media:refresh-metadata', description: 'Refresh meta information')]
final class RefreshMetadataCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 6.0 is dropped.
protected static $defaultName = 'sonata:media:refresh-metadata';
protected static $defaultDescription = 'Refresh meta information';

Expand All @@ -55,6 +58,7 @@ 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
4 changes: 4 additions & 0 deletions src/Command/RemoveThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -30,8 +31,10 @@
*
* Useful if you have existing media content and added new formats.
*/
#[AsCommand(name: 'sonata:media:remove-thumbnails', description: 'Remove uploaded image thumbs')]
final class RemoveThumbsCommand extends Command
{
// TODO: Remove static properties when support for Symfony < 6.0 is dropped.
protected static $defaultName = 'sonata:media:remove-thumbnails';
protected static $defaultDescription = 'Remove uploaded image thumbs';

Expand All @@ -57,6 +60,7 @@ 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
4 changes: 4 additions & 0 deletions src/Command/SyncThumbsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -30,8 +31,10 @@
*
* Useful if you have existing media content and added new formats.
*/
#[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 < 6.0 is dropped.
protected static $defaultName = 'sonata:media:sync-thumbnails';
protected static $defaultDescription = 'Sync uploaded image thumbs with new media formats';

Expand All @@ -57,6 +60,7 @@ 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
4 changes: 4 additions & 0 deletions src/Command/UpdateCdnStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -29,8 +30,10 @@
*
* @author Javier Spagnoletti <phansys@gmail.com>
*/
#[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 < 6.0 is dropped.
protected static $defaultName = 'sonata:media:update-cdn-status';
protected static $defaultDescription = 'Updates model media with the current CDN status';

Expand All @@ -56,6 +59,7 @@ 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: 8 additions & 0 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Sonata\AdminBundle\SonataAdminBundle;
use Sonata\BlockBundle\Cache\HttpCacheHandler;
use Sonata\BlockBundle\SonataBlockBundle;
use Sonata\Doctrine\Bridge\Symfony\SonataDoctrineBundle;
use Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle;
Expand Down Expand Up @@ -91,6 +92,9 @@ protected function configureRoutes($routes): void
$routes->import(__DIR__.'/Resources/config/routing/routes.yaml');
}

/**
* @psalm-suppress DeprecatedClass
*/
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load(__DIR__.'/Resources/config/config.yaml');
Expand All @@ -101,6 +105,10 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
$loader->load(__DIR__.'/Resources/config/config_symfony_v4.yaml');
}

if (class_exists(HttpCacheHandler::class)) {
$loader->load(__DIR__.'/Resources/config/config_sonata_block_v4.yaml');
}

$loader->load(__DIR__.'/Resources/config/services.php');
$container->setParameter('app.base_dir', $this->getBaseDir());
}
Expand Down
1 change: 1 addition & 0 deletions tests/App/Resources/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ framework:
enable_annotations: false
router:
utf8: true
http_method_override: false

security:
role_hierarchy: null
Expand Down
2 changes: 2 additions & 0 deletions tests/App/Resources/config/config_sonata_block_v4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonata_block:
http_cache: false

0 comments on commit b1161c4

Please sign in to comment.