-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[FrameworkBundle] forward-compatibility with HttpKernel 5 #33356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,11 +132,10 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
$domain = $input->getOption('domain'); | ||
/** @var KernelInterface $kernel */ | ||
$kernel = $this->getApplication()->getKernel(); | ||
$rootDir = $kernel->getContainer()->getParameter('kernel.root_dir'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
// Define Root Paths | ||
$transPaths = $this->transPaths; | ||
if (is_dir($dir = $rootDir.'/Resources/translations')) { | ||
if ($kernel->getContainer()->hasParameter('kernel.root_dir') && is_dir($dir = $kernel->getContainer()->getParameter('kernel.root_dir').'/Resources/translations')) { | ||
if ($dir !== $this->defaultTransPath) { | ||
$notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir); | ||
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); | ||
|
@@ -147,7 +146,7 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
$transPaths[] = $this->defaultTransPath; | ||
} | ||
$viewsPaths = $this->viewsPaths; | ||
if (is_dir($dir = $rootDir.'/Resources/views')) { | ||
if ($kernel->getContainer()->hasParameter('kernel.root_dir') && is_dir($dir = $kernel->getContainer()->getParameter('kernel.root_dir').'/Resources/views')) { | ||
if ($dir !== $this->defaultViewsPath) { | ||
$notice = sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, ', $dir); | ||
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); | ||
|
@@ -168,15 +167,15 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
if ($this->defaultTransPath) { | ||
$transPaths[] = $this->defaultTransPath; | ||
} | ||
if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { | ||
if ($kernel->getContainer()->hasParameter('kernel.root_dir') && is_dir($dir = sprintf('%s/Resources/%s/translations', $kernel->getContainer()->getParameter('kernel.root_dir'), $bundle->getName()))) { | ||
$transPaths[] = $dir; | ||
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $dir, $bundle->getName()); | ||
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); | ||
} | ||
if ($this->defaultViewsPath) { | ||
$viewsPaths[] = $this->defaultViewsPath; | ||
} | ||
if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { | ||
if ($kernel->getContainer()->hasParameter('kernel.root_dir') && is_dir($dir = sprintf('%s/Resources/%s/views', $kernel->getContainer()->getParameter('kernel.root_dir'), $bundle->getName()))) { | ||
$viewsPaths[] = $dir; | ||
$notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir); | ||
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); | ||
|
@@ -210,12 +209,12 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
$bundleDir = $bundle->getPath(); | ||
$transPaths[] = is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundle->getPath().'/translations'; | ||
$viewsPaths[] = is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundle->getPath().'/templates'; | ||
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { | ||
if ($kernel->getContainer()->hasParameter('kernel.root_dir') && is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $kernel->getContainer()->getParameter('kernel.root_dir'), $bundle->getName()))) { | ||
$transPaths[] = $deprecatedPath; | ||
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); | ||
@trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); | ||
} | ||
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { | ||
if ($kernel->getContainer()->hasParameter('kernel.root_dir') && is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $kernel->getContainer()->getParameter('kernel.root_dir'), $bundle->getName()))) { | ||
$viewsPaths[] = $deprecatedPath; | ||
$notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); | ||
@trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ | |
<service id="templating.finder" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder"> | ||
<argument type="service" id="kernel" /> | ||
<argument type="service" id="templating.filename_parser" /> | ||
<argument>%kernel.root_dir%/Resources</argument> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there another way to get this path for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what we can do here. The parameter will be gone with HttpKernel 5 and the class will be dropped in FrameworkBundle 5 too. I don't see what would be the fallback value here. The only safe solution probably would be to not allow HttpKernel 5. |
||
|
||
<deprecated>The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0.</deprecated> | ||
</service> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ | |
|
||
<service id="twig.template_iterator" class="Symfony\Bundle\TwigBundle\TemplateIterator"> | ||
<argument type="service" id="kernel" /> | ||
<argument>%kernel.root_dir%</argument> | ||
<argument /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, we should update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this argument needs to be deprecated to get rid of it in 5.0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see how this would solve the BC break. If the parameter isn't present, asking the kernel for the parameter doesn't solve that. |
||
<argument type="collection" /> <!-- Twig paths --> | ||
<argument>%twig.default_path%</argument> | ||
</service> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we use
$this->kernel->getContainer()->hasParameter('kernel.root_dir')
here as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have the container here. We inject the argument depending on the presence of the parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we have the kernel instance, no?
$this->kernel->getContainer()
?