[HttpKernel] deprecated usage of getRootDir() and kernel.root_dir
This commit is contained in:
parent
5fda7e2fb1
commit
0b851c6956
@ -177,6 +177,12 @@ HttpFoundation
|
|||||||
* The default value of the "$secure" and "$samesite" arguments of Cookie's constructor
|
* The default value of the "$secure" and "$samesite" arguments of Cookie's constructor
|
||||||
changed respectively from "false" to "null" and from "null" to "lax".
|
changed respectively from "false" to "null" and from "null" to "lax".
|
||||||
|
|
||||||
|
HttpKernel
|
||||||
|
----------
|
||||||
|
|
||||||
|
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed
|
||||||
|
* The `KernelInterface::getName()` and the `kernel.name` parameter have been removed
|
||||||
|
|
||||||
Monolog
|
Monolog
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
|||||||
if ($container->hasParameter('cache.prefix.seed')) {
|
if ($container->hasParameter('cache.prefix.seed')) {
|
||||||
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
|
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
|
||||||
} else {
|
} else {
|
||||||
$seed = '_'.$container->getParameter('kernel.root_dir');
|
$seed = '_'.$container->getParameter('kernel.project_dir');
|
||||||
}
|
}
|
||||||
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
|
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
|
||||||
$namespace = 'sf_'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.ContainerBuilder::hash($seed);
|
$namespace = 'sf_'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.ContainerBuilder::hash($seed);
|
||||||
|
@ -272,7 +272,7 @@ class DoctrineExtensionTest extends TestCase
|
|||||||
'kernel.debug' => false,
|
'kernel.debug' => false,
|
||||||
'kernel.environment' => 'test',
|
'kernel.environment' => 'test',
|
||||||
'kernel.container_class' => 'kernel',
|
'kernel.container_class' => 'kernel',
|
||||||
'kernel.root_dir' => __DIR__,
|
'kernel.project_dir' => __DIR__,
|
||||||
), $data)));
|
), $data)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,6 @@ EOT
|
|||||||
array('Environment', $kernel->getEnvironment()),
|
array('Environment', $kernel->getEnvironment()),
|
||||||
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
|
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
|
||||||
array('Charset', $kernel->getCharset()),
|
array('Charset', $kernel->getCharset()),
|
||||||
array('Root directory', self::formatPath($kernel->getRootDir(), $kernel->getProjectDir())),
|
|
||||||
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
|
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
|
||||||
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
|
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
|
||||||
new TableSeparator(),
|
new TableSeparator(),
|
||||||
|
@ -130,11 +130,11 @@ EOF
|
|||||||
$kernel = $this->getApplication()->getKernel();
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
|
||||||
// Define Root Paths
|
// Define Root Paths
|
||||||
$transPaths = array($kernel->getRootDir().'/Resources/translations');
|
$transPaths = array($kernel->getRootDir(false).'/Resources/translations');
|
||||||
if ($this->defaultTransPath) {
|
if ($this->defaultTransPath) {
|
||||||
$transPaths[] = $this->defaultTransPath;
|
$transPaths[] = $this->defaultTransPath;
|
||||||
}
|
}
|
||||||
$viewsPaths = array($kernel->getRootDir().'/Resources/views');
|
$viewsPaths = array($kernel->getRootDir(false).'/Resources/views');
|
||||||
if ($this->defaultViewsPath) {
|
if ($this->defaultViewsPath) {
|
||||||
$viewsPaths[] = $this->defaultViewsPath;
|
$viewsPaths[] = $this->defaultViewsPath;
|
||||||
}
|
}
|
||||||
@ -147,12 +147,12 @@ EOF
|
|||||||
if ($this->defaultTransPath) {
|
if ($this->defaultTransPath) {
|
||||||
$transPaths[] = $this->defaultTransPath.'/'.$bundle->getName();
|
$transPaths[] = $this->defaultTransPath.'/'.$bundle->getName();
|
||||||
}
|
}
|
||||||
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName());
|
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(false), $bundle->getName());
|
||||||
$viewsPaths = array($bundle->getPath().'/Resources/views');
|
$viewsPaths = array($bundle->getPath().'/Resources/views');
|
||||||
if ($this->defaultViewsPath) {
|
if ($this->defaultViewsPath) {
|
||||||
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName();
|
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName();
|
||||||
}
|
}
|
||||||
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName());
|
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(false), $bundle->getName());
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
// such a bundle does not exist, so treat the argument as path
|
// such a bundle does not exist, so treat the argument as path
|
||||||
$transPaths = array($input->getArgument('bundle').'/Resources/translations');
|
$transPaths = array($input->getArgument('bundle').'/Resources/translations');
|
||||||
@ -168,12 +168,12 @@ EOF
|
|||||||
if ($this->defaultTransPath) {
|
if ($this->defaultTransPath) {
|
||||||
$transPaths[] = $this->defaultTransPath.'/'.$bundle->getName();
|
$transPaths[] = $this->defaultTransPath.'/'.$bundle->getName();
|
||||||
}
|
}
|
||||||
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName());
|
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(false), $bundle->getName());
|
||||||
$viewsPaths[] = $bundle->getPath().'/Resources/views';
|
$viewsPaths[] = $bundle->getPath().'/Resources/views';
|
||||||
if ($this->defaultViewsPath) {
|
if ($this->defaultViewsPath) {
|
||||||
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName();
|
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName();
|
||||||
}
|
}
|
||||||
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName());
|
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(false), $bundle->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +120,11 @@ EOF
|
|||||||
$kernel = $this->getApplication()->getKernel();
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
|
||||||
// Define Root Paths
|
// Define Root Paths
|
||||||
$transPaths = array($kernel->getRootDir().'/Resources/translations');
|
$transPaths = array($kernel->getRootDir(false).'/Resources/translations');
|
||||||
if ($this->defaultTransPath) {
|
if ($this->defaultTransPath) {
|
||||||
$transPaths[] = $this->defaultTransPath;
|
$transPaths[] = $this->defaultTransPath;
|
||||||
}
|
}
|
||||||
$viewsPaths = array($kernel->getRootDir().'/Resources/views');
|
$viewsPaths = array($kernel->getRootDir(false).'/Resources/views');
|
||||||
if ($this->defaultViewsPath) {
|
if ($this->defaultViewsPath) {
|
||||||
$viewsPaths[] = $this->defaultViewsPath;
|
$viewsPaths[] = $this->defaultViewsPath;
|
||||||
}
|
}
|
||||||
@ -138,12 +138,12 @@ EOF
|
|||||||
if ($this->defaultTransPath) {
|
if ($this->defaultTransPath) {
|
||||||
$transPaths[] = $this->defaultTransPath.'/'.$foundBundle->getName();
|
$transPaths[] = $this->defaultTransPath.'/'.$foundBundle->getName();
|
||||||
}
|
}
|
||||||
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $foundBundle->getName());
|
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(false), $foundBundle->getName());
|
||||||
$viewsPaths = array($foundBundle->getPath().'/Resources/views');
|
$viewsPaths = array($foundBundle->getPath().'/Resources/views');
|
||||||
if ($this->defaultViewsPath) {
|
if ($this->defaultViewsPath) {
|
||||||
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$foundBundle->getName();
|
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$foundBundle->getName();
|
||||||
}
|
}
|
||||||
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $foundBundle->getName());
|
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(false), $foundBundle->getName());
|
||||||
$currentName = $foundBundle->getName();
|
$currentName = $foundBundle->getName();
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
// such a bundle does not exist, so treat the argument as path
|
// such a bundle does not exist, so treat the argument as path
|
||||||
|
@ -16,22 +16,30 @@ use Symfony\Component\Templating\Helper\Helper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
*/
|
*/
|
||||||
class CodeHelper extends Helper
|
class CodeHelper extends Helper
|
||||||
{
|
{
|
||||||
protected $fileLinkFormat;
|
protected $fileLinkFormat;
|
||||||
|
/**
|
||||||
|
* @deprecated since Symfony 4.2
|
||||||
|
*/
|
||||||
protected $rootDir;
|
protected $rootDir;
|
||||||
protected $charset;
|
protected $charset;
|
||||||
|
|
||||||
|
private $projectDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
|
* @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
|
||||||
* @param string $rootDir The project root directory
|
* @param string $projectDir The project root directory
|
||||||
* @param string $charset The charset
|
* @param string $charset The charset
|
||||||
*/
|
*/
|
||||||
public function __construct($fileLinkFormat, string $rootDir, string $charset)
|
public function __construct($fileLinkFormat, string $projectDir, string $charset)
|
||||||
{
|
{
|
||||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||||
$this->rootDir = str_replace('\\', '/', $rootDir).'/';
|
$this->projectDir = str_replace('\\', '/', $projectDir).'/';
|
||||||
|
$this->rootDir = $this->projectDir;
|
||||||
$this->charset = $charset;
|
$this->charset = $charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +164,10 @@ class CodeHelper extends Helper
|
|||||||
if (null === $text) {
|
if (null === $text) {
|
||||||
$file = trim($file);
|
$file = trim($file);
|
||||||
$fileStr = $file;
|
$fileStr = $file;
|
||||||
if (0 === strpos($fileStr, $this->rootDir)) {
|
if (0 === strpos($fileStr, $this->projectDir)) {
|
||||||
$fileStr = str_replace(array('\\', $this->rootDir), array('/', ''), $fileStr);
|
$fileStr = str_replace(array('\\', $this->projectDir), array('/', ''), $fileStr);
|
||||||
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
|
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
|
||||||
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
|
$fileStr = sprintf('<abbr title="%s">kernel.project_dir</abbr>/%s', htmlspecialchars($this->projectDir, $flags, $this->charset), $fileStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = sprintf('%s at line %d', $fileStr, $line);
|
$text = sprintf('%s at line %d', $fileStr, $line);
|
||||||
|
@ -27,20 +27,20 @@ class CacheClearCommandTest extends TestCase
|
|||||||
private $kernel;
|
private $kernel;
|
||||||
/** @var Filesystem */
|
/** @var Filesystem */
|
||||||
private $fs;
|
private $fs;
|
||||||
private $rootDir;
|
private $projectDir;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->fs = new Filesystem();
|
$this->fs = new Filesystem();
|
||||||
$this->kernel = new TestAppKernel('test', true);
|
$this->kernel = new TestAppKernel('test', true);
|
||||||
$this->rootDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('sf_cache_', true);
|
$this->projectDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('sf_cache_', true);
|
||||||
$this->kernel->setRootDir($this->rootDir);
|
$this->kernel->setProjectDir($this->projectDir);
|
||||||
$this->fs->mkdir($this->rootDir);
|
$this->fs->mkdir($this->projectDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
$this->fs->remove($this->rootDir);
|
$this->fs->remove($this->projectDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCacheIsFreshAfterCacheClearedWithWarmup()
|
public function testCacheIsFreshAfterCacheClearedWithWarmup()
|
||||||
|
@ -26,9 +26,19 @@ class TestAppKernel extends Kernel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRootDir($rootDir)
|
public function setProjectDir($projectDir)
|
||||||
{
|
{
|
||||||
$this->rootDir = $rootDir;
|
$this->projectDir = $projectDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCacheDir()
|
||||||
|
{
|
||||||
|
return $this->getProjectDir().'/Tests/Fixtures/cache.'.$this->environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLogDir()
|
||||||
|
{
|
||||||
|
return $this->getProjectDir().'/Tests/Fixtures/logs';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||||
|
@ -32,7 +32,7 @@ class CachePoolClearerPassTest extends TestCase
|
|||||||
$container->setParameter('kernel.debug', false);
|
$container->setParameter('kernel.debug', false);
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
|
|
||||||
$globalClearer = new Definition(Psr6CacheClearer::class);
|
$globalClearer = new Definition(Psr6CacheClearer::class);
|
||||||
$container->setDefinition('cache.global_clearer', $globalClearer);
|
$container->setDefinition('cache.global_clearer', $globalClearer);
|
||||||
|
@ -37,7 +37,7 @@ class CachePoolPassTest extends TestCase
|
|||||||
$container->setParameter('kernel.debug', false);
|
$container->setParameter('kernel.debug', false);
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
$adapter = new Definition();
|
$adapter = new Definition();
|
||||||
$adapter->setAbstract(true);
|
$adapter->setAbstract(true);
|
||||||
$adapter->addTag('cache.pool');
|
$adapter->addTag('cache.pool');
|
||||||
@ -58,7 +58,7 @@ class CachePoolPassTest extends TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
|
|
||||||
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
|
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class CachePoolPassTest extends TestCase
|
|||||||
$container->setParameter('kernel.debug', false);
|
$container->setParameter('kernel.debug', false);
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
$adapter = new Definition();
|
$adapter = new Definition();
|
||||||
$adapter->setAbstract(true);
|
$adapter->setAbstract(true);
|
||||||
$adapter->addTag('cache.pool');
|
$adapter->addTag('cache.pool');
|
||||||
|
@ -47,14 +47,14 @@ class AppKernel extends Kernel
|
|||||||
|
|
||||||
public function registerBundles()
|
public function registerBundles()
|
||||||
{
|
{
|
||||||
if (!file_exists($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) {
|
if (!file_exists($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {
|
||||||
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
return include $filename;
|
return include $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRootDir()
|
public function getProjectDir()
|
||||||
{
|
{
|
||||||
return __DIR__;
|
return __DIR__;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
framework:
|
framework:
|
||||||
secret: test
|
secret: test
|
||||||
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
|
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
|
||||||
validation: { enabled: true, enable_annotations: true }
|
validation: { enabled: true, enable_annotations: true }
|
||||||
csrf_protection: true
|
csrf_protection: true
|
||||||
form: true
|
form: true
|
||||||
|
@ -53,14 +53,14 @@ class AppKernel extends Kernel
|
|||||||
|
|
||||||
public function registerBundles()
|
public function registerBundles()
|
||||||
{
|
{
|
||||||
if (!is_file($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) {
|
if (!is_file($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {
|
||||||
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
return include $filename;
|
return include $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRootDir()
|
public function getProjectDir()
|
||||||
{
|
{
|
||||||
return __DIR__;
|
return __DIR__;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
framework:
|
framework:
|
||||||
secret: test
|
secret: test
|
||||||
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
|
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
|
||||||
validation: { enabled: true, enable_annotations: true }
|
validation: { enabled: true, enable_annotations: true }
|
||||||
csrf_protection: true
|
csrf_protection: true
|
||||||
form: true
|
form: true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
framework:
|
framework:
|
||||||
secret: test
|
secret: test
|
||||||
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
|
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
|
||||||
validation: { enabled: true, enable_annotations: true }
|
validation: { enabled: true, enable_annotations: true }
|
||||||
assets: ~
|
assets: ~
|
||||||
csrf_protection: true
|
csrf_protection: true
|
||||||
|
@ -50,7 +50,7 @@ class CachePoolPass implements CompilerPassInterface
|
|||||||
if ($container->hasParameter('cache.prefix.seed')) {
|
if ($container->hasParameter('cache.prefix.seed')) {
|
||||||
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
|
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
|
||||||
} else {
|
} else {
|
||||||
$seed = '_'.$container->getParameter('kernel.root_dir');
|
$seed = '_'.$container->getParameter('kernel.project_dir');
|
||||||
}
|
}
|
||||||
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment');
|
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment');
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class CachePoolClearerPassTest extends TestCase
|
|||||||
$container->setParameter('kernel.debug', false);
|
$container->setParameter('kernel.debug', false);
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
|
|
||||||
$globalClearer = new Definition(Psr6CacheClearer::class);
|
$globalClearer = new Definition(Psr6CacheClearer::class);
|
||||||
$container->setDefinition('cache.global_clearer', $globalClearer);
|
$container->setDefinition('cache.global_clearer', $globalClearer);
|
||||||
|
@ -34,7 +34,7 @@ class CachePoolPassTest extends TestCase
|
|||||||
$container->setParameter('kernel.debug', false);
|
$container->setParameter('kernel.debug', false);
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
$adapter = new Definition();
|
$adapter = new Definition();
|
||||||
$adapter->setAbstract(true);
|
$adapter->setAbstract(true);
|
||||||
$adapter->addTag('cache.pool');
|
$adapter->addTag('cache.pool');
|
||||||
@ -55,7 +55,7 @@ class CachePoolPassTest extends TestCase
|
|||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
|
|
||||||
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
|
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ class CachePoolPassTest extends TestCase
|
|||||||
$container->setParameter('kernel.debug', false);
|
$container->setParameter('kernel.debug', false);
|
||||||
$container->setParameter('kernel.container_class', 'app');
|
$container->setParameter('kernel.container_class', 'app');
|
||||||
$container->setParameter('kernel.environment', 'prod');
|
$container->setParameter('kernel.environment', 'prod');
|
||||||
$container->setParameter('kernel.root_dir', 'foo');
|
$container->setParameter('kernel.project_dir', 'foo');
|
||||||
$adapter = new Definition();
|
$adapter = new Definition();
|
||||||
$adapter->setAbstract(true);
|
$adapter->setAbstract(true);
|
||||||
$adapter->addTag('cache.pool');
|
$adapter->addTag('cache.pool');
|
||||||
|
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
4.2.0
|
4.2.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* deprecated `Kernel::getRootDir()` and the `kernel.root_dir` parameter
|
||||||
* deprecated `KernelInterface::getName()` and the `kernel.name` parameter
|
* deprecated `KernelInterface::getName()` and the `kernel.name` parameter
|
||||||
|
|
||||||
4.1.0
|
4.1.0
|
||||||
|
@ -54,6 +54,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
protected $bundles = array();
|
protected $bundles = array();
|
||||||
|
|
||||||
protected $container;
|
protected $container;
|
||||||
|
/**
|
||||||
|
* @deprecated since Symfony 4.2
|
||||||
|
*/
|
||||||
protected $rootDir;
|
protected $rootDir;
|
||||||
protected $environment;
|
protected $environment;
|
||||||
protected $debug;
|
protected $debug;
|
||||||
@ -83,7 +86,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
{
|
{
|
||||||
$this->environment = $environment;
|
$this->environment = $environment;
|
||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
$this->rootDir = $this->getRootDir();
|
$this->rootDir = $this->getRootDir(false);
|
||||||
$this->name = $this->getName(false);
|
$this->name = $this->getName(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +284,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $this->name) {
|
if (null === $this->name) {
|
||||||
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
|
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->getProjectDir()));
|
||||||
if (ctype_digit($this->name[0])) {
|
if (ctype_digit($this->name[0])) {
|
||||||
$this->name = '_'.$this->name;
|
$this->name = '_'.$this->name;
|
||||||
}
|
}
|
||||||
@ -308,9 +311,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @deprecated since Symfony 4.2, use getProjectDir() instead
|
||||||
*/
|
*/
|
||||||
public function getRootDir()
|
public function getRootDir(/* $triggerDeprecation = true */)
|
||||||
{
|
{
|
||||||
|
if (0 === \func_num_args() || func_get_arg(0)) {
|
||||||
|
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use getProjectDir() instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
if (null === $this->rootDir) {
|
if (null === $this->rootDir) {
|
||||||
$r = new \ReflectionObject($this);
|
$r = new \ReflectionObject($this);
|
||||||
$this->rootDir = \dirname($r->getFileName());
|
$this->rootDir = \dirname($r->getFileName());
|
||||||
@ -370,7 +379,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
*/
|
*/
|
||||||
public function getCacheDir()
|
public function getCacheDir()
|
||||||
{
|
{
|
||||||
return $this->rootDir.'/cache/'.$this->environment;
|
return $this->getProjectDir().'/var/cache/'.$this->environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -378,7 +387,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
*/
|
*/
|
||||||
public function getLogDir()
|
public function getLogDir()
|
||||||
{
|
{
|
||||||
return $this->rootDir.'/logs';
|
return $this->getProjectDir().'/var/log';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -582,6 +591,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
/*
|
||||||
|
* @deprecated since Symfony 4.2, use kernel.project_dir instead
|
||||||
|
*/
|
||||||
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
|
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
|
||||||
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
|
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
|
||||||
'kernel.environment' => $this->environment,
|
'kernel.environment' => $this->environment,
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\HttpKernel\Tests\Fixtures\_123;
|
|
||||||
|
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
|
||||||
|
|
||||||
class Kernel123 extends Kernel
|
|
||||||
{
|
|
||||||
public function registerBundles()
|
|
||||||
{
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCacheDir()
|
|
||||||
{
|
|
||||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/cache/'.$this->environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLogDir()
|
|
||||||
{
|
|
||||||
return sys_get_temp_dir().'/'.Kernel::VERSION.'/kernel123/logs';
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,4 +34,14 @@ class KernelForTest extends Kernel
|
|||||||
{
|
{
|
||||||
return $this->booted;
|
return $this->booted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCacheDir()
|
||||||
|
{
|
||||||
|
return $this->getProjectDir().'/Tests/Fixtures/cache.'.$this->environment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLogDir()
|
||||||
|
{
|
||||||
|
return $this->getProjectDir().'/Tests/Fixtures/logs';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class KernelTest extends TestCase
|
|||||||
public static function tearDownAfterClass()
|
public static function tearDownAfterClass()
|
||||||
{
|
{
|
||||||
$fs = new Filesystem();
|
$fs = new Filesystem();
|
||||||
$fs->remove(__DIR__.'/Fixtures/cache');
|
$fs->remove(__DIR__.'/Fixtures/var');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
@ -67,15 +67,15 @@ class KernelTest extends TestCase
|
|||||||
public function testInitializeContainerClearsOldContainers()
|
public function testInitializeContainerClearsOldContainers()
|
||||||
{
|
{
|
||||||
$fs = new Filesystem();
|
$fs = new Filesystem();
|
||||||
$legacyContainerDir = __DIR__.'/Fixtures/cache/custom/ContainerA123456';
|
$legacyContainerDir = __DIR__.'/Fixtures/var/cache/custom/ContainerA123456';
|
||||||
$fs->mkdir($legacyContainerDir);
|
$fs->mkdir($legacyContainerDir);
|
||||||
touch($legacyContainerDir.'.legacy');
|
touch($legacyContainerDir.'.legacy');
|
||||||
|
|
||||||
$kernel = new CustomProjectDirKernel();
|
$kernel = new CustomProjectDirKernel();
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
|
$containerDir = __DIR__.'/Fixtures/var/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16);
|
||||||
$this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
|
$this->assertTrue(unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'));
|
||||||
$this->assertFileExists($containerDir);
|
$this->assertFileExists($containerDir);
|
||||||
$this->assertFileNotExists($containerDir.'.legacy');
|
$this->assertFileNotExists($containerDir.'.legacy');
|
||||||
|
|
||||||
@ -295,6 +295,9 @@ EOF;
|
|||||||
$this->assertEquals($expected, $output);
|
$this->assertEquals($expected, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
*/
|
||||||
public function testGetRootDir()
|
public function testGetRootDir()
|
||||||
{
|
{
|
||||||
$kernel = new KernelForTest('test', true);
|
$kernel = new KernelForTest('test', true);
|
||||||
@ -309,7 +312,7 @@ EOF;
|
|||||||
{
|
{
|
||||||
$kernel = new KernelForTest('test', true);
|
$kernel = new KernelForTest('test', true);
|
||||||
|
|
||||||
$this->assertEquals('Fixtures', $kernel->getName());
|
$this->assertEquals('HttpKernel', $kernel->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -512,43 +515,32 @@ EOF;
|
|||||||
$this->assertTrue($kernel->getContainer()->getParameter('test_executed'));
|
$this->assertTrue($kernel->getContainer()->getParameter('test_executed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
public function testKernelRootDirNameStartingWithANumber()
|
|
||||||
{
|
|
||||||
$dir = __DIR__.'/Fixtures/123';
|
|
||||||
require_once $dir.'/Kernel123.php';
|
|
||||||
$kernel = new \Symfony\Component\HttpKernel\Tests\Fixtures\_123\Kernel123('dev', true);
|
|
||||||
$this->assertEquals('_123', $kernel->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testProjectDirExtension()
|
public function testProjectDirExtension()
|
||||||
{
|
{
|
||||||
$kernel = new CustomProjectDirKernel();
|
$kernel = new CustomProjectDirKernel();
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$this->assertSame('foo', $kernel->getProjectDir());
|
$this->assertSame(__DIR__.'/Fixtures', $kernel->getProjectDir());
|
||||||
$this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir'));
|
$this->assertSame(__DIR__.'/Fixtures', $kernel->getContainer()->getParameter('kernel.project_dir'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testKernelReset()
|
public function testKernelReset()
|
||||||
{
|
{
|
||||||
(new Filesystem())->remove(__DIR__.'/Fixtures/cache');
|
(new Filesystem())->remove(__DIR__.'/Fixtures/var/cache');
|
||||||
|
|
||||||
$kernel = new CustomProjectDirKernel();
|
$kernel = new CustomProjectDirKernel();
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$containerClass = \get_class($kernel->getContainer());
|
$containerClass = \get_class($kernel->getContainer());
|
||||||
$containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
|
$containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName();
|
||||||
unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
|
unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
|
||||||
|
|
||||||
$kernel = new CustomProjectDirKernel();
|
$kernel = new CustomProjectDirKernel();
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$this->assertInstanceOf($containerClass, $kernel->getContainer());
|
$this->assertInstanceOf($containerClass, $kernel->getContainer());
|
||||||
$this->assertFileExists($containerFile);
|
$this->assertFileExists($containerFile);
|
||||||
unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
|
unlink(__DIR__.'/Fixtures/var/cache/custom/Symfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta');
|
||||||
|
|
||||||
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
|
$kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); });
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
@ -720,7 +712,6 @@ class CustomProjectDirKernel extends Kernel
|
|||||||
{
|
{
|
||||||
parent::__construct($env, true);
|
parent::__construct($env, true);
|
||||||
|
|
||||||
$this->baseDir = 'foo';
|
|
||||||
$this->buildContainer = $buildContainer;
|
$this->buildContainer = $buildContainer;
|
||||||
$this->httpKernel = $httpKernel;
|
$this->httpKernel = $httpKernel;
|
||||||
}
|
}
|
||||||
@ -734,17 +725,7 @@ class CustomProjectDirKernel extends Kernel
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getContainerClass()
|
|
||||||
{
|
|
||||||
return $this->name.parent::getContainerClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getProjectDir()
|
public function getProjectDir()
|
||||||
{
|
|
||||||
return $this->baseDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRootDir()
|
|
||||||
{
|
{
|
||||||
return __DIR__.'/Fixtures';
|
return __DIR__.'/Fixtures';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user