Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb09dfd9

Browse files
feature#31021 [Cache] Added command for list all available cache pools (Nyholm)
This PR was squashed before being merged into the 4.3-dev branch (closes#31021).Discussion----------[Cache] Added command for list all available cache pools| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |symfony/symfony-docs#9782| License | MIT| Doc PR |Commits-------5c210e6 [Cache] Added command for list all available cache pools
2 parents2243bf5 +5c210e6 commitb09dfd9

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ CHANGELOG
3131
* Added the`messenger:setup-transports` command to setup messenger transports
3232
* Added a`InMemoryTransport` to Messenger. Use it with a DSN starting with`in-memory://`.
3333
* Added`framework.property_access.throw_exception_on_invalid_property_path` config option.
34+
* Added`cache:pool:list` command to list all available cache pools.
3435

3536
4.2.0
3637
-----
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Bundle\FrameworkBundle\Command;
13+
14+
useSymfony\Component\Console\Command\Command;
15+
useSymfony\Component\Console\Input\InputInterface;
16+
useSymfony\Component\Console\Output\OutputInterface;
17+
useSymfony\Component\Console\Style\SymfonyStyle;
18+
19+
/**
20+
* List available cache pools.
21+
*
22+
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
23+
*/
24+
finalclass CachePoolListCommandextends Command
25+
{
26+
protectedstatic$defaultName ='cache:pool:list';
27+
28+
private$poolNames;
29+
30+
publicfunction__construct(array$poolNames)
31+
{
32+
parent::__construct();
33+
34+
$this->poolNames =$poolNames;
35+
}
36+
37+
/**
38+
* {@inheritdoc}
39+
*/
40+
protectedfunctionconfigure()
41+
{
42+
$this
43+
->setDescription('List available cache pools')
44+
->setHelp(<<<'EOF'
45+
The <info>%command.name%</info> command lists all available cache pools.
46+
EOF
47+
)
48+
;
49+
}
50+
51+
/**
52+
* {@inheritdoc}
53+
*/
54+
protectedfunctionexecute(InputInterface$input,OutputInterface$output)
55+
{
56+
$io =newSymfonyStyle($input,$output);
57+
58+
$io->table(['Pool name'],array_map(function ($pool) {
59+
return [$pool];
60+
},$this->poolNames));
61+
}
62+
}

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
<tagname="console.command"command="cache:pool:delete" />
4949
</service>
5050

51+
<serviceid="console.command.cache_pool_list"class="Symfony\Bundle\FrameworkBundle\Command\CachePoolListCommand">
52+
<argument /><!-- Pool names-->
53+
<tagname="console.command"command="cache:pool:list" />
54+
</service>
55+
5156
<serviceid="console.command.cache_warmup"class="Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand">
5257
<argumenttype="service"id="cache_warmer" />
5358
<tagname="console.command"command="cache:warmup" />
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Bundle\FrameworkBundle\Tests\Functional;
13+
14+
useSymfony\Bundle\FrameworkBundle\Command\CachePoolListCommand;
15+
useSymfony\Bundle\FrameworkBundle\Console\Application;
16+
useSymfony\Component\Console\Tester\CommandTester;
17+
18+
/**
19+
* @group functional
20+
*/
21+
class CachePoolListCommandTestextends WebTestCase
22+
{
23+
protectedfunctionsetUp()
24+
{
25+
static::bootKernel(['test_case' =>'CachePools','root_config' =>'config.yml']);
26+
}
27+
28+
publicfunctiontestListPools()
29+
{
30+
$tester =$this->createCommandTester(['cache.app','cache.system']);
31+
$tester->execute([]);
32+
33+
$this->assertSame(0,$tester->getStatusCode(),'cache:pool:list exits with 0 in case of success');
34+
$this->assertContains('cache.app',$tester->getDisplay());
35+
$this->assertContains('cache.system',$tester->getDisplay());
36+
}
37+
38+
publicfunctiontestEmptyList()
39+
{
40+
$tester =$this->createCommandTester([]);
41+
$tester->execute([]);
42+
43+
$this->assertSame(0,$tester->getStatusCode(),'cache:pool:list exits with 0 in case of success');
44+
}
45+
46+
privatefunctioncreateCommandTester(array$poolNames)
47+
{
48+
$application =newApplication(static::$kernel);
49+
$application->add(newCachePoolListCommand($poolNames));
50+
51+
returnnewCommandTester($application->find('cache:pool:list'));
52+
}
53+
}

‎src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public function process(ContainerBuilder $container)
136136
$clearer->addTag($this->cacheSystemClearerTag);
137137
}
138138
}
139+
140+
if ($container->hasDefinition('console.command.cache_pool_list')) {
141+
$container->getDefinition('console.command.cache_pool_list')->replaceArgument(0,array_keys($pools));
142+
}
139143
}
140144

141145
privatefunctiongetNamespace($seed,$id)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp