minor #25115 [*Bundle] Replace some kernel.root_dir by kernel.project_dir (nicolas-grekas, xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[*Bundle] Replace some kernel.root_dir by kernel.project_dir

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

92fc2f7 remove more kernel.root_dir parameter refs
4add28b [*Bundle] Replace some kernel.root_dir by kernel.project_dir
This commit is contained in:
Nicolas Grekas 2017-11-24 12:33:45 +01:00
commit 6cb270702f
21 changed files with 40 additions and 55 deletions

View File

@ -40,7 +40,6 @@ class DebugExtensionTest extends TestCase
{
$container = new ContainerBuilder(new ParameterBag(array(
'kernel.cache_dir' => __DIR__,
'kernel.root_dir' => __DIR__.'/Fixtures',
'kernel.charset' => 'UTF-8',
'kernel.debug' => true,
'kernel.bundles' => array('DebugBundle' => 'Symfony\\Bundle\\DebugBundle\\DebugBundle'),

View File

@ -52,7 +52,7 @@
<service id="templating.helper.code" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper">
<tag name="templating.helper" alias="code" />
<argument type="service" id="debug.file_link_formatter"></argument>
<argument>%kernel.root_dir%</argument>
<argument>%kernel.project_dir%</argument>
<argument>%kernel.charset%</argument>
</service>

View File

@ -21,7 +21,7 @@ $container->loadFromExtension('framework', array(
'enabled' => false,
),
'router' => array(
'resource' => '%kernel.root_dir%/config/routing.xml',
'resource' => '%kernel.project_dir%/config/routing.xml',
'type' => 'xml',
),
'session' => array(
@ -54,7 +54,7 @@ $container->loadFromExtension('framework', array(
'translator' => array(
'enabled' => true,
'fallback' => 'fr',
'paths' => array('%kernel.root_dir%/Fixtures/translations'),
'paths' => array('%kernel.project_dir%/Fixtures/translations'),
),
'validation' => array(
'enabled' => true,

View File

@ -6,9 +6,9 @@ $container->loadFromExtension('framework', array(
'enable_annotations' => true,
'mapping' => array(
'paths' => array(
'%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files',
'%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml',
'%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml',
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files',
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml',
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml',
),
),
),

View File

@ -4,9 +4,9 @@ $container->loadFromExtension('framework', array(
'validation' => array(
'mapping' => array(
'paths' => array(
'%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files',
'%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml',
'%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml',
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files',
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml',
'%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml',
),
),
),

View File

@ -14,7 +14,7 @@
<framework:esi enabled="true" />
<framework:ssi enabled="true" />
<framework:profiler only-exceptions="true" enabled="false" />
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
<framework:router resource="%kernel.project_dir%/config/routing.xml" type="xml" />
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="false" use-cookies="true" save-path="/path/to/sessions" />
<framework:request>
<framework:format name="csv">
@ -37,7 +37,7 @@
</framework:templating>
<framework:assets version="v1" />
<framework:translator enabled="true" fallback="fr" logging="true">
<framework:path>%kernel.root_dir%/Fixtures/translations</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/translations</framework:path>
</framework:translator>
<framework:validation enabled="true" />
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />

View File

@ -8,9 +8,9 @@
<framework:annotations enabled="true" />
<framework:serializer enable-annotations="true">
<framework:mapping>
<framework:path>%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files</framework:path>
<framework:path>%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml</framework:path>
<framework:path>%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml</framework:path>
</framework:mapping>
</framework:serializer>
</framework:config>

View File

@ -7,9 +7,9 @@
<framework:config>
<framework:validation>
<framework:mapping>
<framework:path>%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files</framework:path>
<framework:path>%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml</framework:path>
<framework:path>%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml</framework:path>
<framework:path>%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml</framework:path>
</framework:mapping>
</framework:validation>
</framework:config>

View File

@ -14,7 +14,7 @@ framework:
only_exceptions: true
enabled: false
router:
resource: '%kernel.root_dir%/config/routing.xml'
resource: '%kernel.project_dir%/config/routing.xml'
type: xml
session:
storage_id: session.storage.native
@ -42,8 +42,8 @@ framework:
translator:
enabled: true
fallback: fr
default_path: '%kernel.root_dir%/translations'
paths: ['%kernel.root_dir%/Fixtures/translations']
default_path: '%kernel.project_dir%/translations'
paths: ['%kernel.project_dir%/Fixtures/translations']
validation:
enabled: true
annotations:

View File

@ -5,6 +5,6 @@ framework:
enable_annotations: true
mapping:
paths:
- "%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files"
- "%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml"
- "%kernel.root_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml"
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/files"
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yml"
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/serializer_mapping/serialization.yaml"

View File

@ -2,6 +2,6 @@ framework:
validation:
mapping:
paths:
- "%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files"
- "%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml"
- "%kernel.root_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml"
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/files"
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yml"
- "%kernel.project_dir%/Fixtures/TestBundle/Resources/config/validation_mapping/validation.yaml"

View File

@ -322,7 +322,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertTrue($container->has('router'), '->registerRouterConfiguration() loads routing.xml');
$arguments = $container->findDefinition('router')->getArguments();
$this->assertEquals($container->getParameter('kernel.root_dir').'/config/routing.xml', $container->getParameter('router.resource'), '->registerRouterConfiguration() sets routing resource');
$this->assertEquals($container->getParameter('kernel.project_dir').'/config/routing.xml', $container->getParameter('router.resource'), '->registerRouterConfiguration() sets routing resource');
$this->assertEquals('%router.resource%', $arguments[1], '->registerRouterConfiguration() sets routing resource');
$this->assertEquals('xml', $arguments[2]['resource_type'], '->registerRouterConfiguration() sets routing resource type');
}

View File

@ -22,7 +22,6 @@ class ExtensionPassTest extends TestCase
{
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
$container->setParameter('kernel.root_dir', __DIR__);
$container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable');
$container->register('templating', '\Symfony\Bundle\TwigBundle\TwigEngine');

View File

@ -17,7 +17,7 @@ $container->loadFromExtension('twig', array(
'charset' => 'ISO-8859-1',
'debug' => true,
'strict_variables' => true,
'default_path' => '%kernel.root_dir%/templates',
'default_path' => '%kernel.project_dir%/Fixtures/templates',
'paths' => array(
'path1',
'path2',

View File

@ -6,7 +6,7 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/twig http://symfony.com/schema/dic/twig/twig-1.0.xsd">
<twig:config auto-reload="true" autoescape="true" base-template-class="stdClass" cache="/tmp" charset="ISO-8859-1" debug="true" strict-variables="true" default-path="%kernel.root_dir%/templates">
<twig:config auto-reload="true" autoescape="true" base-template-class="stdClass" cache="/tmp" charset="ISO-8859-1" debug="true" strict-variables="true" default-path="%kernel.project_dir%/Fixtures/templates">
<twig:form-theme>MyBundle::form.html.twig</twig:form-theme>
<twig:global key="foo" id="bar" type="service" />
<twig:global key="baz">@@qux</twig:global>

View File

@ -13,7 +13,7 @@ twig:
charset: ISO-8859-1
debug: true
strict_variables: true
default_path: '%kernel.root_dir%/templates'
default_path: '%kernel.project_dir%/Fixtures/templates'
paths:
path1: ''
path2: ''

View File

@ -99,13 +99,18 @@ class CacheWarmingKernel extends Kernel
$container->loadFromExtension('framework', array(
'secret' => '$ecret',
'templating' => array('engines' => array('twig')),
'router' => array('resource' => '%kernel.root_dir%/Resources/config/empty_routing.yml'),
'router' => array('resource' => '%kernel.project_dir%/Resources/config/empty_routing.yml'),
'form' => array('enabled' => false),
));
});
}
}
public function getProjectDir()
{
return __DIR__;
}
public function getCacheDir()
{
return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment;

View File

@ -53,24 +53,6 @@ class WebProfilerExtension extends Extension
$container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']);
$container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED);
}
$baseDir = array();
$rootDir = $container->getParameter('kernel.root_dir');
$rootDir = explode(DIRECTORY_SEPARATOR, realpath($rootDir) ?: $rootDir);
$bundleDir = explode(DIRECTORY_SEPARATOR, __DIR__);
for ($i = 0; isset($rootDir[$i], $bundleDir[$i]); ++$i) {
if ($rootDir[$i] !== $bundleDir[$i]) {
break;
}
$baseDir[] = $rootDir[$i];
}
$baseDir = implode(DIRECTORY_SEPARATOR, $baseDir);
$profilerController = $container->getDefinition('web_profiler.controller.profiler');
$profilerController->replaceArgument(6, $baseDir);
$fileLinkFormatter = $container->getDefinition('debug.file_link_formatter');
$fileLinkFormatter->replaceArgument(2, $baseDir);
}
/**

View File

@ -14,7 +14,7 @@
<argument>%data_collector.templates%</argument>
<argument>%web_profiler.debug_toolbar.position%</argument>
<argument type="service" id="web_profiler.csp.handler" />
<argument>null</argument>
<argument>%kernel.project_dir%</argument>
</service>
<service id="web_profiler.controller.router" class="Symfony\Bundle\WebProfilerBundle\Controller\RouterController" public="true">
@ -55,7 +55,7 @@
<service id="debug.file_link_formatter" class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter">
<argument>%debug.file_link_format%</argument>
<argument type="service" id="request_stack" on-invalid="ignore" />
<argument>null</argument>
<argument>%kernel.project_dir%</argument>
<argument>/_profiler/open?file=%%f&amp;line=%%l#line%%l</argument>
</service>
</services>

View File

@ -60,7 +60,7 @@ class WebProfilerExtensionTest extends TestCase
$this->container->setParameter('kernel.bundles', array());
$this->container->setParameter('kernel.cache_dir', __DIR__);
$this->container->setParameter('kernel.debug', false);
$this->container->setParameter('kernel.root_dir', __DIR__);
$this->container->setParameter('kernel.project_dir', __DIR__);
$this->container->setParameter('kernel.charset', 'UTF-8');
$this->container->setParameter('debug.file_link_format', null);
$this->container->setParameter('profiler.class', array('Symfony\\Component\\HttpKernel\\Profiler\\Profiler'));

View File

@ -17,7 +17,7 @@
],
"require": {
"php": "^5.5.9|>=7.0.8",
"symfony/http-kernel": "~3.2|~4.0",
"symfony/http-kernel": "~3.3|~4.0",
"symfony/polyfill-php70": "~1.0",
"symfony/routing": "~2.8|~3.0|~4.0",
"symfony/twig-bridge": "~2.8|~3.0|~4.0",