Skip to content

Replace deprecated Command::$defaultName #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/Command/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace FOS\HttpCacheBundle\Command;

use FOS\HttpCache\CacheInvalidator;
use FOS\HttpCacheBundle\CacheManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -21,29 +21,18 @@
*
* @author Alexander Schranz <[email protected]>
*/
#[AsCommand(name: 'fos:httpcache:clear')]
class ClearCommand extends BaseInvalidateCommand
{
use PathSanityCheck;

protected static $defaultName = 'fos:httpcache:clear';

/**
* If no cache manager is specified explicitly, fos_http_cache.cache_manager
* is automatically loaded.
*
* @param CacheManager|null $cacheManager The cache manager to talk to
*/
public function __construct(CacheManager $cacheManager = null)
{
parent::__construct($cacheManager);
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('fos:httpcache:clear')
->setDescription('Clear the HTTP cache.')
->setHelp(
<<<'EOF'
Expand Down
10 changes: 6 additions & 4 deletions src/Command/InvalidatePathCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FOS\HttpCacheBundle\Command;

use FOS\HttpCacheBundle\CacheManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,12 +22,11 @@
*
* @author David Buchmann <[email protected]>
*/
#[AsCommand(name: 'fos:httpcache:invalidate:path')]
class InvalidatePathCommand extends BaseInvalidateCommand
{
use PathSanityCheck;

protected static $defaultName = 'fos:httpcache:invalidate:path';

/**
* If no cache manager is specified explicitly, fos_http_cache.cache_manager
* is automatically loaded.
Expand All @@ -35,11 +35,12 @@ class InvalidatePathCommand extends BaseInvalidateCommand
*/
public function __construct(CacheManager $cacheManager = null)
{
parent::__construct($cacheManager);

if (2 <= func_num_args()) {
@trigger_error('Passing a command name in the constructor is deprecated and will be removed in version 3', E_USER_DEPRECATED);
static::$defaultName = func_get_arg(1);
$this->setName(func_get_arg(1));
}
parent::__construct($cacheManager);
}

/**
Expand All @@ -48,6 +49,7 @@ public function __construct(CacheManager $cacheManager = null)
protected function configure()
{
$this
->setName('fos:httpcache:invalidate:path')
->setDescription('Invalidate cached paths on all configured caching proxies')
->addArgument(
'paths',
Expand Down
10 changes: 6 additions & 4 deletions src/Command/InvalidateRegexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FOS\HttpCacheBundle\Command;

use FOS\HttpCacheBundle\CacheManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -22,10 +23,9 @@
* @author Christian Stocker <[email protected]>
* @author David Buchmann <[email protected]>
*/
#[AsCommand(name: 'fos:httpcache:invalidate:regex')]
class InvalidateRegexCommand extends BaseInvalidateCommand
{
protected static $defaultName = 'fos:httpcache:invalidate:regex';

/**
* If no cache manager is specified explicitly, fos_http_cache.cache_manager
* is automatically loaded.
Expand All @@ -34,11 +34,12 @@ class InvalidateRegexCommand extends BaseInvalidateCommand
*/
public function __construct(CacheManager $cacheManager = null, $commandName = 'fos:httpcache:invalidate:regex')
{
parent::__construct($cacheManager);

if (2 <= func_num_args()) {
@trigger_error('Passing a command name in the constructor is deprecated and will be removed in version 3', E_USER_DEPRECATED);
static::$defaultName = func_get_arg(1);
$this->setName(func_get_arg(1));
}
parent::__construct($cacheManager);
}

/**
Expand All @@ -47,6 +48,7 @@ public function __construct(CacheManager $cacheManager = null, $commandName = 'f
protected function configure()
{
$this
->setName('fos:httpcache:invalidate:regex')
->setDescription('Invalidate everything matching a regular expression on all configured caching proxies')
->addArgument(
'regex',
Expand Down
10 changes: 6 additions & 4 deletions src/Command/InvalidateTagCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FOS\HttpCacheBundle\Command;

use FOS\HttpCacheBundle\CacheManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,10 +22,9 @@
*
* @author David Buchmann <[email protected]>
*/
#[AsCommand(name: 'fos:httpcache:invalidate:tag')]
class InvalidateTagCommand extends BaseInvalidateCommand
{
protected static $defaultName = 'fos:httpcache:invalidate:tag';

/**
* If no cache manager is specified explicitly, fos_http_cache.cache_manager
* is automatically loaded.
Expand All @@ -33,11 +33,12 @@ class InvalidateTagCommand extends BaseInvalidateCommand
*/
public function __construct(CacheManager $cacheManager = null, $commandName = 'fos:httpcache:invalidate:tag')
{
parent::__construct($cacheManager);

if (2 <= func_num_args()) {
@trigger_error('Passing a command name in the constructor is deprecated and will be removed in version 3', E_USER_DEPRECATED);
static::$defaultName = func_get_arg(1);
$this->setName(func_get_arg(1));
}
parent::__construct($cacheManager);
}

/**
Expand All @@ -46,6 +47,7 @@ public function __construct(CacheManager $cacheManager = null, $commandName = 'f
protected function configure()
{
$this
->setName('fos:httpcache:invalidate:tag')
->setDescription('Invalidate cached content matching the specified tags on all configured caching proxies')
->addArgument(
'tags',
Expand Down
10 changes: 6 additions & 4 deletions src/Command/RefreshPathCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FOS\HttpCacheBundle\Command;

use FOS\HttpCacheBundle\CacheManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,12 +22,11 @@
*
* @author David Buchmann <[email protected]>
*/
#[AsCommand(name: 'fos:httpcache:refresh:path')]
class RefreshPathCommand extends BaseInvalidateCommand
{
use PathSanityCheck;

protected static $defaultName = 'fos:httpcache:refresh:path';

/**
* If no cache manager is specified explicitly, fos_http_cache.cache_manager
* is automatically loaded.
Expand All @@ -35,11 +35,12 @@ class RefreshPathCommand extends BaseInvalidateCommand
*/
public function __construct(CacheManager $cacheManager = null)
{
parent::__construct($cacheManager);

if (2 <= func_num_args()) {
@trigger_error('Passing a command name in the constructor is deprecated and will be removed in version 3', E_USER_DEPRECATED);
static::$defaultName = func_get_arg(1);
$this->setName(func_get_arg(1));
}
parent::__construct($cacheManager);
}

/**
Expand All @@ -48,6 +49,7 @@ public function __construct(CacheManager $cacheManager = null)
protected function configure()
{
$this
->setName('fos:httpcache:refresh:path')
->setDescription('Refresh paths on all configured caching proxies')
->addArgument(
'paths',
Expand Down