Skip to content

Commit 52337fe

Browse files
committed
remove deprecated global resource dir and kernel.root_dir
1 parent 9e88855 commit 52337fe

File tree

15 files changed

+17
-188
lines changed

15 files changed

+17
-188
lines changed

src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public function getDebugTemplateNameTestData()
254254

255255
public function testDebugTemplateNameWithChainLoader()
256256
{
257-
$tester = $this->createCommandTester(['templates/' => null], [], null, null, true);
257+
$tester = $this->createCommandTester(['templates/' => null], [], null, true);
258258
$ret = $tester->execute(['name' => 'base.html.twig'], ['decorated' => false]);
259259

260260
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
@@ -264,7 +264,7 @@ public function testDebugTemplateNameWithChainLoader()
264264
public function testWithGlobals()
265265
{
266266
$message = '<error>foo</error>';
267-
$tester = $this->createCommandTester([], [], null, null, false, ['message' => $message]);
267+
$tester = $this->createCommandTester([], [], null, false, ['message' => $message]);
268268
$tester->execute([], ['decorated' => true]);
269269
$display = $tester->getDisplay();
270270
$this->assertStringContainsString(json_encode($message), $display);
@@ -273,7 +273,7 @@ public function testWithGlobals()
273273
public function testWithGlobalsJson()
274274
{
275275
$globals = ['message' => '<error>foo</error>'];
276-
$tester = $this->createCommandTester([], [], null, null, false, $globals);
276+
$tester = $this->createCommandTester([], [], null, false, $globals);
277277
$tester->execute(['--format' => 'json'], ['decorated' => true]);
278278
$display = $tester->getDisplay();
279279
$display = json_decode($display, true);
@@ -292,7 +292,7 @@ public function testWithFilter()
292292
$this->assertNotSame($display1, $display2);
293293
}
294294

295-
private function createCommandTester(array $paths = [], array $bundleMetadata = [], string $defaultPath = null, string $rootDir = null, bool $useChainLoader = false, array $globals = []): CommandTester
295+
private function createCommandTester(array $paths = [], array $bundleMetadata = [], string $defaultPath = null, bool $useChainLoader = false, array $globals = []): CommandTester
296296
{
297297
$projectDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
298298
$loader = new FilesystemLoader([], $projectDir);
@@ -314,7 +314,7 @@ private function createCommandTester(array $paths = [], array $bundleMetadata =
314314
}
315315

316316
$application = new Application();
317-
$application->add(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, null, $rootDir));
317+
$application->add(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, null));
318318
$command = $application->find('debug:twig');
319319

320320
return new CommandTester($command);

src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@
8787

8888
<service id="file_locator" class="Symfony\Component\HttpKernel\Config\FileLocator">
8989
<argument type="service" id="kernel" />
90-
<argument>%kernel.root_dir%/Resources</argument>
91-
<argument type="collection">
92-
<argument>%kernel.root_dir%</argument>
93-
</argument>
94-
<argument>false</argument>
9590
</service>
9691
<service id="Symfony\Component\HttpKernel\Config\FileLocator" alias="file_locator" />
9792

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
1616
use Symfony\Bundle\FrameworkBundle\Console\Application;
1717
use Symfony\Component\Console\Tester\CommandTester;
18-
use Symfony\Component\DependencyInjection\Container;
1918
use Symfony\Component\Filesystem\Filesystem;
2019

2120
class TranslationDebugCommandTest extends TestCase
@@ -170,14 +169,6 @@ function ($path, $catalogue) use ($loadedMessages) {
170169
->method('getBundles')
171170
->willReturn([]);
172171

173-
$container = new Container();
174-
$container->setParameter('kernel.root_dir', $this->translationDir);
175-
176-
$kernel
177-
->expects($this->any())
178-
->method('getContainer')
179-
->willReturn($container);
180-
181172
$command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths);
182173

183174
$application = new Application($kernel);

src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
1616
use Symfony\Bundle\FrameworkBundle\Console\Application;
1717
use Symfony\Component\Console\Tester\CommandTester;
18-
use Symfony\Component\DependencyInjection\Container;
1918
use Symfony\Component\Filesystem\Filesystem;
2019
use Symfony\Component\HttpKernel;
2120

@@ -159,13 +158,6 @@ function ($path, $catalogue) use ($loadedMessages) {
159158
->method('getBundles')
160159
->willReturn([]);
161160

162-
$container = new Container();
163-
$container->setParameter('kernel.root_dir', $this->translationDir);
164-
$kernel
165-
->expects($this->any())
166-
->method('getContainer')
167-
->willReturn($container);
168-
169161
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths);
170162

171163
$application = new Application($kernel);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,6 @@ protected function createContainer(array $data = [])
13911391
'kernel.debug' => false,
13921392
'kernel.environment' => 'test',
13931393
'kernel.name' => 'kernel',
1394-
'kernel.root_dir' => __DIR__,
13951394
'kernel.container_class' => 'testContainer',
13961395
'container.build_hash' => 'Abc1234',
13971396
'container.build_id' => hash('crc32', 'Abc123423456789'),

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/DependencyInjection/SecurityExtensionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ public function testRememberMeCookieInheritFrameworkSessionCookie($config, $same
346346
$container->registerExtension(new FrameworkExtension());
347347
$container->setParameter('kernel.bundles_metadata', []);
348348
$container->setParameter('kernel.project_dir', __DIR__);
349-
$container->setParameter('kernel.root_dir', __DIR__);
350349
$container->setParameter('kernel.cache_dir', __DIR__);
351350

352351
$container->loadFromExtension('security', [

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,10 @@ public function testRuntimeLoader()
262262
$this->assertEquals('foo', $args['FooClass']->getValues()[0]);
263263
}
264264

265-
private function createContainer(string $rootDir = __DIR__.'/Fixtures')
265+
private function createContainer()
266266
{
267267
$container = new ContainerBuilder(new ParameterBag([
268268
'kernel.cache_dir' => __DIR__,
269-
'kernel.root_dir' => $rootDir,
270269
'kernel.project_dir' => __DIR__,
271270
'kernel.charset' => 'UTF-8',
272271
'kernel.debug' => false,

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ CHANGELOG
2222
* added method `getProjectDir()` to `KernelInterface`
2323
* removed methods `serialize` and `unserialize` from `DataCollector`, store the serialized state in the data property instead
2424
* made `ProfilerStorageInterface` internal
25+
* removed the second and third argument of `KernelInterface::locateResource`
26+
* removed the second and third argument of `FileLocator::__construct`
27+
* removed loading resources from `%kernel.root_dir%/Resources` and `%kernel.root_dir%` as
28+
fallback directories.
2529

2630
4.4.0
2731
-----

src/Symfony/Component/HttpKernel/Config/FileLocator.php

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,11 @@ class FileLocator extends BaseFileLocator
2323
{
2424
private $kernel;
2525

26-
/**
27-
* @deprecated since Symfony 4.4
28-
*/
29-
private $path;
30-
31-
public function __construct(KernelInterface $kernel/*, string $path = null, array $paths = [], bool $triggerDeprecation = true*/)
26+
public function __construct(KernelInterface $kernel)
3227
{
3328
$this->kernel = $kernel;
3429

35-
if (2 <= \func_num_args()) {
36-
$this->path = func_get_arg(1);
37-
$paths = 3 <= \func_num_args() ? func_get_arg(2) : [];
38-
if (null !== $this->path) {
39-
$paths[] = $this->path;
40-
}
41-
42-
if (4 !== \func_num_args() || func_get_arg(3)) {
43-
@trigger_error(sprintf('Passing more than one argument to %s is deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__), E_USER_DEPRECATED);
44-
}
45-
} else {
46-
$paths = [];
47-
}
48-
49-
parent::__construct($paths);
30+
parent::__construct();
5031
}
5132

5233
/**
@@ -55,32 +36,11 @@ public function __construct(KernelInterface $kernel/*, string $path = null, arra
5536
public function locate(string $file, string $currentPath = null, bool $first = true)
5637
{
5738
if (isset($file[0]) && '@' === $file[0]) {
58-
return $this->kernel->locateResource($file, $this->path, $first, false);
59-
}
60-
61-
$locations = parent::locate($file, $currentPath, $first);
39+
$resource = $this->kernel->locateResource($file);
6240

63-
if (isset($file[0]) && !(
64-
'/' === $file[0] || '\\' === $file[0]
65-
|| (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && ('\\' === $file[2] || '/' === $file[2]))
66-
|| null !== parse_url($file, PHP_URL_SCHEME)
67-
)) {
68-
// no need to trigger deprecations when the loaded file is given as absolute path
69-
foreach ($this->paths as $deprecatedPath) {
70-
if (\is_array($locations)) {
71-
foreach ($locations as $location) {
72-
if (0 === strpos($location, $deprecatedPath) && (null === $currentPath || false === strpos($location, $currentPath))) {
73-
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
74-
}
75-
}
76-
} else {
77-
if (0 === strpos($locations, $deprecatedPath) && (null === $currentPath || false === strpos($locations, $currentPath))) {
78-
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
79-
}
80-
}
81-
}
41+
return $first ? $resource : [$resource];
8242
}
8343

84-
return $locations;
44+
return parent::locate($file, $currentPath, $first);
8545
}
8646
}

0 commit comments

Comments
 (0)