-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle][FrameworkBundle] Fixed that Twig cache warmer is not being added as cache warmer #15034
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
Closed
Closed
[TwigBundle][FrameworkBundle] Fixed that Twig cache warmer is not being added as cache warmer #15034
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/CacheWarmer/CacheWarmer.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\CacheWarmer; | ||
|
||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; | ||
|
||
class CacheWarmer implements CacheWarmerInterface | ||
{ | ||
public function warmUp($cacheDir) | ||
{ | ||
$filesystem = new Filesystem(); | ||
$filesystem->mkdir($cacheDir.'/cache_warmer'); | ||
} | ||
|
||
public function isOptional() | ||
{ | ||
return true; | ||
} | ||
} | ||
16 changes: 16 additions & 0 deletions
16
...undle/Tests/Functional/Bundle/TestBundle/DependencyInjection/Compiler/CacheWarmerPass.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class CacheWarmerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if ($container->hasDefinition('cache_warmer_test.cache_warmer')) { | ||
$container->getDefinition('cache_warmer_test.cache_warmer')->addTag('kernel.cache_warmer'); | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. newline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CacheWarmerTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
class CacheWarmerTest extends WebTestCase | ||
{ | ||
/** | ||
* @var Application | ||
*/ | ||
private $application; | ||
|
||
protected function setUp() | ||
{ | ||
$kernel = static::createKernel(array('test_case' => 'CacheWarmer', 'root_config' => 'config.yml')); | ||
$this->application = new Application($kernel); | ||
$this->application->doRun(new ArrayInput(array()), new NullOutput()); | ||
} | ||
|
||
public function testCacheWarmer() | ||
{ | ||
$tester = $this->createCommandTester(); | ||
$tester->execute(array()); | ||
|
||
$cacheDirectory = $this->application->getKernel()->getCacheDir().'/cache_warmer'; | ||
$this->assertTrue(file_exists($cacheDirectory), 'Cache directory does not exist.'); | ||
} | ||
|
||
/** | ||
* @return CommandTester | ||
*/ | ||
private function createCommandTester() | ||
{ | ||
$command = $this->application->find('cache:warmup'); | ||
|
||
return new CommandTester($command); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CacheWarmer/bundles.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
|
||
return array( | ||
new FrameworkBundle(), | ||
new TestBundle(), | ||
); |
10 changes: 10 additions & 0 deletions
10
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CacheWarmer/config.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
imports: | ||
- { resource: ../config/default.yml } | ||
|
||
framework: | ||
templating: | ||
engines: ['php'] | ||
|
||
services: | ||
cache_warmer_test.cache_warmer: | ||
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\CacheWarmer\CacheWarmer |
2 changes: 2 additions & 0 deletions
2
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/CacheWarmer/routing.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_templatecachetest_bundle: | ||
resource: @TestBundle/Resources/config/routing.yml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing newline