diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 5b0f2ddbe305a..b2891b4afa070 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -367,7 +367,7 @@ protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheD } else { $seed = '_'.$container->getParameter('kernel.root_dir'); } - $seed .= '.'.$container->getParameter('kernel.name').'.'.$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); $cacheDriver['namespace'] = $namespace; diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 008cbd987d1ef..5d4d1ee48c68c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -271,7 +271,7 @@ protected function createContainer(array $data = array()) 'kernel.cache_dir' => __DIR__, 'kernel.debug' => false, 'kernel.environment' => 'test', - 'kernel.name' => 'kernel', + 'kernel.container_class' => 'kernel', 'kernel.root_dir' => __DIR__, ), $data))); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php index 930de24466b91..4128f57e13c8a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php @@ -71,7 +71,6 @@ protected function execute(InputInterface $input, OutputInterface $output) array('Kernel'), new TableSeparator(), array('Type', \get_class($kernel)), - array('Name', $kernel->getName()), array('Environment', $kernel->getEnvironment()), array('Debug', $kernel->isDebug() ? 'true' : 'false'), array('Charset', $kernel->getCharset()), diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php index be733f995ccbb..1246f37b09300 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php @@ -148,7 +148,7 @@ public function all($namespace = null) */ public function getLongVersion() { - return parent::getLongVersion().sprintf(' (kernel: %s, env: %s, debug: %s)', $this->kernel->getName(), $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false'); + return parent::getLongVersion().sprintf(' (env: %s, debug: %s)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false'); } public function add(Command $command) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php index 7e5dad6fa4a83..69aea35439cdd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolClearerPassTest.php @@ -30,7 +30,7 @@ public function testPoolRefsAreWeak() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php index 7c3337f9e4a6f..d1f594f2905dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/CachePoolPassTest.php @@ -35,7 +35,7 @@ public function testNamespaceArgumentIsReplaced() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $adapter = new Definition(); @@ -57,7 +57,7 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed() { $container = new ContainerBuilder(); $container->setParameter('kernel.environment', 'prod'); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.root_dir', 'foo'); $container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0); @@ -75,7 +75,7 @@ public function testArgsAreReplaced() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('cache.prefix.seed', 'foo'); $cachePool = new Definition(); @@ -100,7 +100,7 @@ public function testWithNameAttribute() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('cache.prefix.seed', 'foo'); $cachePool = new Definition(); @@ -126,7 +126,7 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $adapter = new Definition(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index 1aab514f45450..00f9e371d006a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -46,13 +46,9 @@ public function __construct($varDir, $testCase, $rootConfig, $environment, $debu /** * {@inheritdoc} */ - public function getName() + public function getContainerClass() { - if (null === $this->name) { - $this->name = parent::getName().substr(md5($this->rootConfig), -16); - } - - return $this->name; + return parent::getContainerClass().substr(md5($this->rootConfig), -16); } public function registerBundles() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 6e5b9608b4f43..c6d49f0208722 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -50,13 +50,6 @@ - {% if 'n/a' is not same as(collector.appname) %} -
- Kernel name - {{ collector.appname }} -
- {% endif %} - {% if 'n/a' is not same as(collector.env) %}
Environment diff --git a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php index b04c47dea1466..51d21639ec6aa 100644 --- a/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php +++ b/src/Symfony/Component/Cache/DependencyInjection/CachePoolPass.php @@ -52,7 +52,7 @@ public function process(ContainerBuilder $container) } else { $seed = '_'.$container->getParameter('kernel.root_dir'); } - $seed .= '.'.$container->getParameter('kernel.name').'.'.$container->getParameter('kernel.environment'); + $seed .= '.'.$container->getParameter('kernel.container_class').'.'.$container->getParameter('kernel.environment'); $pools = array(); $clearers = array(); diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php index 3d151e10628b8..9ce46f9d146b8 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolClearerPassTest.php @@ -27,7 +27,7 @@ public function testPoolRefsAreWeak() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); diff --git a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php index 4054c20df973d..5890c57e94cb9 100644 --- a/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php +++ b/src/Symfony/Component/Cache/Tests/DependencyInjection/CachePoolPassTest.php @@ -32,7 +32,7 @@ public function testNamespaceArgumentIsReplaced() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $adapter = new Definition(); @@ -54,7 +54,7 @@ public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed() { $container = new ContainerBuilder(); $container->setParameter('kernel.environment', 'prod'); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.root_dir', 'foo'); $container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0); @@ -72,7 +72,7 @@ public function testArgsAreReplaced() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('cache.prefix.seed', 'foo'); $cachePool = new Definition(); @@ -97,7 +97,7 @@ public function testWithNameAttribute() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('cache.prefix.seed', 'foo'); $cachePool = new Definition(); @@ -123,7 +123,7 @@ public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() { $container = new ContainerBuilder(); $container->setParameter('kernel.debug', false); - $container->setParameter('kernel.name', 'app'); + $container->setParameter('kernel.container_class', 'app'); $container->setParameter('kernel.environment', 'prod'); $container->setParameter('kernel.root_dir', 'foo'); $adapter = new Definition(); diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index c98d2235e333d..41590f736865d 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.2.0 +----- + + * deprecated `KernelInterface::getName()` and the `kernel.name` parameter + 4.1.0 ----- diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 76ad4a8c889a2..3343042481ba5 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -60,7 +60,7 @@ public function collect(Request $request, Response $response, \Exception $except 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, 'symfony_state' => 'unknown', - 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', + 'name' => 'n/a', 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, @@ -227,6 +227,8 @@ public function getPhpTimezone() * Gets the application name. * * @return string The application name + * + * @deprecated since Symfony 4.2 */ public function getAppName() { diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 3c1d257494400..c55c0ddaf9700 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -55,6 +55,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl protected $environment; protected $debug; protected $booted = false; + /** + * @deprecated since Symfony 4.2 + */ protected $name; protected $startTime; @@ -78,7 +81,7 @@ public function __construct(string $environment, bool $debug) $this->environment = $environment; $this->debug = $debug; $this->rootDir = $this->getRootDir(); - $this->name = $this->getName(); + $this->name = $this->getName(false); } public function __clone() @@ -268,8 +271,12 @@ public function locateResource($name, $dir = null, $first = true) /** * {@inheritdoc} */ - public function getName() + public function getName(/* $triggerDeprecation = true */) { + if (0 === \func_num_args() || func_get_arg(0)) { + @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); + } + if (null === $this->name) { $this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir)); if (ctype_digit($this->name[0])) { @@ -421,7 +428,7 @@ protected function build(ContainerBuilder $container) */ protected function getContainerClass() { - return $this->name.ucfirst($this->environment).($this->debug ? 'Debug' : '').'ProjectContainer'; + return str_replace('\\', '_', \get_class($this)).ucfirst($this->environment).($this->debug ? 'Debug' : '').'Container'; } /** @@ -576,6 +583,9 @@ protected function getKernelParameters() 'kernel.project_dir' => realpath($this->getProjectDir()) ?: $this->getProjectDir(), 'kernel.environment' => $this->environment, 'kernel.debug' => $this->debug, + /* + * @deprecated since Symfony 4.2 + */ 'kernel.name' => $this->name, 'kernel.cache_dir' => realpath($cacheDir = $this->warmupDir ?: $this->getCacheDir()) ?: $cacheDir, 'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(), diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/Component/HttpKernel/KernelInterface.php index 485f3bf8424b3..6d04c625781b7 100644 --- a/src/Symfony/Component/HttpKernel/KernelInterface.php +++ b/src/Symfony/Component/HttpKernel/KernelInterface.php @@ -100,6 +100,8 @@ public function locateResource($name, $dir = null, $first = true); * Gets the name of the kernel. * * @return string The kernel name + * + * @deprecated since Symfony 4.2 */ public function getName(); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index a99e34ad4288d..b54af42d7d2ef 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -30,7 +30,7 @@ public function testCollect() $this->assertSame('test', $c->getEnv()); $this->assertTrue($c->isDebug()); $this->assertSame('config', $c->getName()); - $this->assertSame('testkernel', $c->getAppName()); + $this->assertSame('n/a', $c->getAppName()); $this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); $this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 8926f20878c5d..56d18e24d7e69 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -75,7 +75,7 @@ public function testInitializeContainerClearsOldContainers() $kernel->boot(); $containerDir = __DIR__.'/Fixtures/cache/custom/'.substr(\get_class($kernel->getContainer()), 0, 16); - $this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta')); + $this->assertTrue(unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta')); $this->assertFileExists($containerDir); $this->assertFileNotExists($containerDir.'.legacy'); @@ -302,6 +302,9 @@ public function testGetRootDir() $this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures', realpath($kernel->getRootDir())); } + /** + * @group legacy + */ public function testGetName() { $kernel = new KernelForTest('test', true); @@ -309,6 +312,9 @@ public function testGetName() $this->assertEquals('Fixtures', $kernel->getName()); } + /** + * @group legacy + */ public function testOverrideGetName() { $kernel = new KernelForOverrideName('test', true); @@ -506,6 +512,9 @@ public function testKernelWithoutBundles() $this->assertTrue($kernel->getContainer()->getParameter('test_executed')); } + /** + * @group legacy + */ public function testKernelRootDirNameStartingWithANumber() { $dir = __DIR__.'/Fixtures/123'; @@ -532,14 +541,14 @@ public function testKernelReset() $containerClass = \get_class($kernel->getContainer()); $containerFile = (new \ReflectionClass($kernel->getContainer()))->getFileName(); - unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'); + unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'); $kernel = new CustomProjectDirKernel(); $kernel->boot(); $this->assertInstanceOf($containerClass, $kernel->getContainer()); $this->assertFileExists($containerFile); - unlink(__DIR__.'/Fixtures/cache/custom/FixturesCustomDebugProjectContainer.php.meta'); + unlink(__DIR__.'/Fixtures/cache/custom/FixturesSymfony_Component_HttpKernel_Tests_CustomProjectDirKernelCustomDebugContainer.php.meta'); $kernel = new CustomProjectDirKernel(function ($container) { $container->register('foo', 'stdClass')->setPublic(true); }); $kernel->boot(); @@ -707,9 +716,9 @@ class CustomProjectDirKernel extends Kernel private $buildContainer; private $httpKernel; - public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $name = 'custom') + public function __construct(\Closure $buildContainer = null, HttpKernelInterface $httpKernel = null, $env = 'custom') { - parent::__construct($name, true); + parent::__construct($env, true); $this->baseDir = 'foo'; $this->buildContainer = $buildContainer; @@ -725,6 +734,11 @@ public function registerContainerConfiguration(LoaderInterface $loader) { } + protected function getContainerClass() + { + return $this->name.parent::getContainerClass(); + } + public function getProjectDir() { return $this->baseDir; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy