Skip to content
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
14 changes: 14 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$kernelDir = \dirname((new \ReflectionObject($kernel))->getFileName());
$preloadFile = $fs->makePathRelative(\dirname($containerFile, 2), $kernelDir);
$preloadFile .= substr_replace(basename($containerFile), '.preload', -4, 0);
$preloadFile = var_export('/'.$preloadFile, true);
@file_put_contents($kernelDir.'/preload.php', <<<EOPHP
<?php

if (file_exists(__DIR__.$preloadFile)) {
require __DIR__.$preloadFile;
}

EOPHP
);

if ($output->isVerbose()) {
$io->comment('Finished');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function setUp(): void
protected function tearDown(): void
{
$this->fs->remove($this->kernel->getProjectDir());
$this->fs->remove(__DIR__.'/Fixture/preload.php');
}

public function testCacheIsFreshAfterCacheClearedWithWarmup()
Expand Down Expand Up @@ -82,5 +83,7 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup()
$containerRef = new \ReflectionClass(require $containerFile);
$containerFile = str_replace('tes_'.\DIRECTORY_SEPARATOR, 'test'.\DIRECTORY_SEPARATOR, $containerRef->getFileName());
$this->assertMatchesRegularExpression(sprintf('/\'kernel.container_class\'\s*=>\s*\'%s\'/', $containerClass), file_get_contents($containerFile), 'kernel.container_class is properly set on the dumped container');

$this->assertFileEquals(__DIR__.'/Fixture/preload.php.expected', __DIR__.'/Fixture/preload.php');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

if (file_exists(__DIR__.'/test/var/cache/test/FixtureSymfony_Bundle_FrameworkBundle_Tests_Command_CacheClearCommand_Fixture_TestAppKernelTestDebugContainer.preload.php')) {
require __DIR__.'/test/var/cache/test/FixtureSymfony_Bundle_FrameworkBundle_Tests_Command_CacheClearCommand_Fixture_TestAppKernelTestDebugContainer.preload.php';
}