8000 removed some internal usage of kernel.project_dir · symfony/symfony@086826e · GitHub
[go: up one dir, main page]

Skip to content

Commit 086826e

Browse files
committed
removed some internal usage of kernel.project_dir
1 parent 61d336b commit 086826e

File tree

18 files changed

+41
-33
lines changed

18 files changed

+41
-33
lines changed

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

Lines 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.name').'.'.$container->getParameter('kernel.environment').'.'.$container->getParameter('kernel.debug');
371371
$namespace = 'sf_'.$this->getMappingResourceExtension().'_'.$objectManagerName.'_'.ContainerBuilder::hash($seed);

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

Lines 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.name' => 'kernel',
275-
'kernel.root_dir' => __DIR__,
275+
'kernel.project_dir' => __DIR__,
276276
), $data)));
277277
}
278278
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
7575
array('Environment', $kernel->getEnvironment()),
7676
array('Debug', $kernel->isDebug() ? 'true' : 'false'),
7777
array('Charset', $kernel->getCharset()),
78-
array('Root directory', self::formatPath($kernel->getRootDir(), $kernel->getProjectDir())),
7978
array('Cache directory', self::formatPath($kernel->getCacheDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getCacheDir()).'</>)'),
8079
array('Log directory', self::formatPath($kernel->getLogDir(), $kernel->getProjectDir()).' (<comment>'.self::formatFileSize($kernel->getLogDir()).'</>)'),
8180
new TableSeparator(),

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,29 @@
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;
29+
protected $projectDir;
2430
protected $charset;
2531

2632
/**
2733
* @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
28-
* @param string $rootDir The project root directory
34+
* @param string $projectDir The project root directory
2935
* @param string $charset The charset
3036
*/
31-
public function __construct($fileLinkFormat, string $rootDir, string $charset)
37+
public function __construct($fileLinkFormat, string $projectDir, string $charset)
3238
{
3339
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
34-
$this->rootDir = str_replace('\\', '/', $rootDir).'/';
40+
$this->projectDir = str_replace('\\', '/', $projectDir).'/';
41+
$this->rootDir = $this->projectDir;
3542
$this->charset = $charset;
3643
}
3744

@@ -156,10 +163,10 @@ public function formatFile($file, $line, $text = null)
156163
if (null === $text) {
157164
$file = trim($file);
158165
$fileStr = $file;
159-
if (0 === strpos($fileStr, $this->rootDir)) {
160-
$fileStr = str_replace(array('\\', $this->rootDir), array('/', ''), $fileStr);
166+
if (0 === strpos($fileStr, $this->projectDir)) {
167+
$fileStr = str_replace(array('\\', $this->projectDir), array('/', ''), $fileStr);
161168
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
162-
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
169+
$fileStr = sprintf('<abbr title="%s">kernel.project_dir</abbr>/%s', htmlspecialchars($this->projectDir, $flags, $this->charset), $fileStr);
163170
}
164171

165172
$text = sprintf('%s at line %d', $fileStr, $line);

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

Lines 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('sf2_cache_', true);
37-
$this->kernel->setRootDir($this->rootDir);
38-
$this->fs->mkdir($this->rootDir);
36+
$this->projectDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('sf2_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()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ 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;
3232
}
3333

3434
public function registerContainerConfiguration(LoaderInterface $loader)

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

Lines 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.name', '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);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testNamespaceArgumentIsReplaced()
3737
$container->setParameter('kernel.debug', false);
3838
$container->setParameter('kernel.name', 'app');
3939
$container->setParameter('kernel.environment', 'prod');
40-
$container->setParameter('kernel.root_dir', 'foo');
40+
$container->setParameter('kernel.project_dir', 'foo');
4141
$adapter = new Definition();
4242
$adapter->setAbstract(true);
4343
$adapter->addTag('cache.pool');
@@ -58,7 +58,7 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
5858
$container = new ContainerBuilder();
5959
$container->setParameter('kernel.environment', 'prod');
6060
$container->setParameter('kernel.name', 'app');
61-
$container->setParameter('kernel.root_dir', 'foo');
61+
$container->setParameter('kernel.project_dir', 'foo');
6262

6363
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
6464

@@ -128,7 +128,7 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
128128
$container->setParameter('kernel.debug', false);
129129
$container->setParameter('kernel.name', 'app');
130130
$container->setParameter('kernel.environment', 'prod');
131-
$container->setParameter('kernel.root_dir', 'foo');
131+
$container->setParameter('kernel.project_dir', 'foo');
132132
$adapter = new Definition();
133133
$adapter->setAbstract(true);
134134
$adapter->addTag('cache.pool');

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public function __construct($varDir, $testCase, $rootConfig, $environment, $debu
4747

4848
public function registerBundles()
4949
{
50-
if (!file_exists($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) {
50+
if (!file_exists($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {
5151
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
5252
}
5353

5454
return include $filename;
5555
}
5656

57-
public function getRootDir()
57+
public function getProjectDir()
5858
{
5959
return __DIR__;
6060
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/config/framework.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
framework:
22
secret: test
3-
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
3+
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
44
validation: { enabled: true, enable_annotations: true }
55
csrf_protection: true
66
form: true

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ private function createContainer($sessionStorageOptions)
125125
$container->setParameter('kernel.container_class', 'cc');
126126
$container->setParameter('kernel.debug', true);
127127
$container->setParameter('kernel.project_dir', __DIR__);
128-
$container->setParameter('kernel.root_dir', __DIR__);
129128
$container->setParameter('kernel.secret', __DIR__);
130129
if (null !== $sessionStorageOptions) {
131130
$container->setParameter('session.storage.options', $sessionStorageOptions);

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public function getName()
5757

5858
public function registerBundles()
5959
{
60-
if (!is_file($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) {
60+
if (!is_file($filename = $this->getProjectDir().'/'.$this->testCase.'/bundles.php')) {
6161
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename));
6262
}
6363

6464
return include $filename;
6565
}
6666

67-
public function getRootDir()
67+
public function getProjectDir()
6868
{
6969
return __DIR__;
7070
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/FirewallEntryPoint/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
framework:
22
secret: test
3-
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
3+
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
44
validation: { enabled: true, enable_annotations: true }
55
csrf_protection: true
66
form: true

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
framework:
22
secret: test
3-
router: { resource: "%kernel.root_dir%/%kernel.test_case%/routing.yml" }
3+
router: { resource: "%kernel.project_dir%/%kernel.test_case%/routing.yml" }
44
validation: { enabled: true, enable_annotations: true }
55
assets: ~
66
csrf_protection: true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function process(ContainerBuilder $container)
5050
if ($container->hasParameter('cache.prefix.seed')) {
5151
$seed = '.'.$container->getParameterBag()->resolveValue($container->getParameter('cache.prefix.seed'));
5252
} else {
53-
$seed = '_'.$container->getParameter('kernel.root_dir');
53+
$seed = '_'.$container->getParameter('kernel.project_dir');
5454
}
5555
$seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment');
5656

src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testPoolRefsAreWeak()
2929
$container->setParameter('kernel.debug', false);
3030
$container->setParameter('kernel.name', 'app');
3131
$container->setParameter('kernel.environment', 'prod');
32-
$container->setParameter('kernel.root_dir', 'foo');
32+
$container->setParameter('kernel.project_dir', 'foo');
3333

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

src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testNamespaceArgumentIsReplaced()
3434
$container->setParameter('kernel.debug', false);
3535
$container->setParameter('kernel.name', 'app');
3636
$container->setParameter('kernel.environment', 'prod');
37-
$container->setParameter('kernel.root_dir', 'foo');
37+
$container->setParameter('kernel.project_dir', 'foo');
3838
$adapter = new Definition();
3939
$adapter->setAbstract(true);
4040
$adapter->addTag('cache.pool');
@@ -55,7 +55,7 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
5555
$container = new ContainerBuilder();
5656
$container->setParameter('kernel.environment', 'prod');
5757
$container->setParameter('kernel.name', 'app');
58-
$container->setParameter('kernel.root_dir', 'foo');
58+
$container->setParameter('kernel.project_dir', 'foo');
5959

6060
$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);
6161

@@ -125,7 +125,7 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes()
125125
$container->setParameter('kernel.debug', false);
126126
$container->setParameter('kernel.name', 'app');
127127
$container->setParameter('kernel.environment', 'prod');
128-
$container->setParameter('kernel.root_dir', 'foo');
128+
$container->setParameter('kernel.project_dir', 'foo');
129129
$adapter = new Definition();
130130
$adapter->setAbstract(true);
131131
$adapter->addTag('cache.pool');

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ protected function getKernelParameters()
572572
}
573573

574574
return array(
575+
/**
576+
* @deprecated since Symfony 3.3
577+
*/
575578
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
576579
'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(),
577580
'kernel.environment' => $this->environment,

0 commit comments

Comments
 (0)
0