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

Appearance settings

Commit 0b851c6

Browse filesBrowse files
committed
[HttpKernel] deprecated usage of getRootDir() and kernel.root_dir
1 parent 5fda7e2 commit 0b851c6
Copy full SHA for 0b851c6

File tree

Expand file treeCollapse file tree

24 files changed

+106
-116
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

24 files changed

+106
-116
lines changed
Open diff view settings
Collapse file

‎UPGRADE-5.0.md‎

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ HttpFoundation
177177
* The default value of the "$secure" and "$samesite" arguments of Cookie's constructor
178178
changed respectively from "false" to "null" and from "null" to "lax".
179179

180+
HttpKernel
181+
----------
182+
183+
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed
184+
* The `KernelInterface::getName()` and the `kernel.name` parameter have been removed
185+
180186
Monolog
181187
-------
182188

Collapse file

‎src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD
365365
if ($container->hasParameter('cache.prefix.seed')) {
366366
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
367367
} else {
368-
$seed = '_'.$container->getParameter('kernel.root_dir');
368+
$seed = '_'.$container->getParameter('kernel.project_dir');
369369
}
370370
$seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
371371
$namespace = 'sf_'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.ContainerBuilder::hash($seed);
Collapse file

‎src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ protected function createContainer(array $data = array())
272272
'kernel.debug' => false,
273273
'kernel.environment' => 'test',
274274
'kernel.container_class' => 'kernel',
275-
'kernel.root_dir' => __DIR__,
275+
'kernel.project_dir' => __DIR__,
276276
), $data)));
277277
}
278278
}
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
7474
array('Environment', $kernel->getEnvironment()),
7575
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
7676
array('Charset', $kernel->getCharset()),
77-
array('Root directory', self::formatPath($kernel->getRootDir(), $kernel->getProjectDir())),
7877
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
7978
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
8079
new TableSeparator(),
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
130130
$kernel = $this->getApplication()->getKernel();
131131

132132
// Define Root Paths
133-
$transPaths = array($kernel->getRootDir().'/Resources/translations');
133+
$transPaths = array($kernel->getRootDir(false).'/Resources/translations');
134134
if ($this->defaultTransPath) {
135135
$transPaths[] = $this->defaultTransPath;
136136
}
137-
$viewsPaths = array($kernel->getRootDir().'/Resources/views');
137+
$viewsPaths = array($kernel->getRootDir(false).'/Resources/views');
138138
if ($this->defaultViewsPath) {
139139
$viewsPaths[] = $this->defaultViewsPath;
140140
}
@@ -147,12 +147,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
147147
if ($this->defaultTransPath) {
148148
$transPaths[] = $this->defaultTransPath.'/'.$bundle->getName();
149149
}
150-
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName());
150+
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(false), $bundle->getName());
151151
$viewsPaths = array($bundle->getPath().'/Resources/views');
152152
if ($this->defaultViewsPath) {
153153
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName();
154154
}
155-
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName());
155+
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(false), $bundle->getName());
156156
} catch (\InvalidArgumentException $e) {
157157
// such a bundle does not exist, so treat the argument as path
158158
$transPaths = array($input->getArgument('bundle').'/Resources/translations');
@@ -168,12 +168,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
168168
if ($this->defaultTransPath) {
169169
$transPaths[] = $this->defaultTransPath.'/'.$bundle->getName();
170170
}
171-
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $bundle->getName());
171+
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(false), $bundle->getName());
172172
$viewsPaths[] = $bundle->getPath().'/Resources/views';
173173
if ($this->defaultViewsPath) {
174174
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$bundle->getName();
175175
}
176-
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $bundle->getName());
176+
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(false), $bundle->getName());
177177
}
178178
}
179179

Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
120120
$kernel = $this->getApplication()->getKernel();
121121

122122
// Define Root Paths
123-
$transPaths = array($kernel->getRootDir().'/Resources/translations');
123+
$transPaths = array($kernel->getRootDir(false).'/Resources/translations');
124124
if ($this->defaultTransPath) {
125125
$transPaths[] = $this->defaultTransPath;
126126
}
127-
$viewsPaths = array($kernel->getRootDir().'/Resources/views');
127+
$viewsPaths = array($kernel->getRootDir(false).'/Resources/views');
128128
if ($this->defaultViewsPath) {
129129
$viewsPaths[] = $this->defaultViewsPath;
130130
}
@@ -138,12 +138,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
138138
if ($this->defaultTransPath) {
139139
$transPaths[] = $this->defaultTransPath.'/'.$foundBundle->getName();
140140
}
141-
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(), $foundBundle->getName());
141+
$transPaths[] = sprintf('%s/Resources/%s/translations', $kernel->getRootDir(false), $foundBundle->getName());
142142
$viewsPaths = array($foundBundle->getPath().'/Resources/views');
143143
if ($this->defaultViewsPath) {
144144
$viewsPaths[] = $this->defaultViewsPath.'/bundles/'.$foundBundle->getName();
145145
}
146-
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(), $foundBundle->getName());
146+
$viewsPaths[] = sprintf('%s/Resources/%s/views', $kernel->getRootDir(false), $foundBundle->getName());
147147
$currentName = $foundBundle->getName();
148148
} catch (\InvalidArgumentException $e) {
149149
// such a bundle does not exist, so treat the argument as path
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php
+14-6Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,30 @@
1616

1717
/**
1818
* @author Fabien Potencier <fabien@symfony.com>
19+
*
20+
* @internal
1921
*/
2022
class CodeHelper extends Helper
2123
{
2224
protected $fileLinkFormat;
25+
/**
26+
* @deprecated since Symfony 4.2
27+
*/
2328
protected $rootDir;
2429
protected $charset;
2530

31+
private $projectDir;
32+
2633
/**
2734
* @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
28-
* @param string $rootDir The project root directory
35+
* @param string $projectDir The project root directory
2936
* @param string $charset The charset
3037
*/
31-
public function __construct($fileLinkFormat, string $rootDir, string $charset)
38+
public function __construct($fileLinkFormat, string $projectDir, string $charset)
3239
{
3340
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
34-
$this->rootDir = str_replace('\\', '/', $rootDir).'/';
41+
$this->projectDir = str_replace('\\', '/', $projectDir).'/';
42+
$this->rootDir = $this->projectDir;
3543
$this->charset = $charset;
3644
}
3745

@@ -156,10 +164,10 @@ public function formatFile($file, $line, $text = null)
156164
if (null === $text) {
157165
$file = trim($file);
158166
$fileStr = $file;
159-
if (0 === strpos($fileStr, $this->rootDir)) {
160-
$fileStr = str_replace(array('\\', $this->rootDir), array('/', ''), $fileStr);
167+
if (0 === strpos($fileStr, $this->projectDir)) {
168+
$fileStr = str_replace(array('\\', $this->projectDir), array('/', ''), $fileStr);
161169
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
162-
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
170+
$fileStr = sprintf('<abbr title="%s">kernel.project_dir</abbr>/%s', htmlspecialchars($this->projectDir, $flags, $this->charset), $fileStr);
163171
}
164172

165173
$text = sprintf('%s at line %d', $fileStr, $line);
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ class CacheClearCommandTest extends TestCase
2727
private $kernel;
2828
/** @var Filesystem */
2929
private $fs;
30-
private $rootDir;
30+
private $projectDir;
3131

3232
protected function setUp()
3333
{
3434
$this->fs = new Filesystem();
3535
$this->kernel = new TestAppKernel('test', true);
36-
$this->rootDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('sf_cache_', true);
37-
$this->kernel->setRootDir($this->rootDir);
38-
$this->fs->mkdir($this->rootDir);
36+
$this->projectDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('sf_cache_', true);
37+
$this->kernel->setProjectDir($this->projectDir);
38+
$this->fs->mkdir($this->projectDir);
3939
}
4040

4141
protected function tearDown()
4242
{
43-
$this->fs->remove($this->rootDir);
43+
$this->fs->remove($this->projectDir);
4444
}
4545

4646
public function testCacheIsFreshAfterCacheClearedWithWarmup()
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@ public function registerBundles()
2626
);
2727
}
2828

29-
public function setRootDir($rootDir)
29+
public function setProjectDir($projectDir)
3030
{
31-
$this->rootDir = $rootDir;
31+
$this->projectDir = $projectDir;
32+
}
33+
34+
public function getCacheDir()
35+
{
36+
return $this->getProjectDir().'/Tests/Fixtures/cache.'.$this->environment;
37+
}
38+
39+
public function getLogDir()
40+
{
41+
return $this->getProjectDir().'/Tests/Fixtures/logs';
3242
}
3343

3444
public function registerContainerConfiguration(LoaderInterface $loader)
Collapse file

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testPoolRefsAreWeak()
3232
$container->setParameter('kernel.debug', false);
3333
$container->setParameter('kernel.container_class', 'app');
3434
$container->setParameter('kernel.environment', 'prod');
35-
$container->setParameter('kernel.root_dir', 'foo');
35+
$container->setParameter('kernel.project_dir', 'foo');
3636

3737
$globalClearer = new Definition(Psr6CacheClearer::class);
3838
$container->setDefinition('cache.global_clearer', $globalClearer);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.