[FrameworkBundle] Add argument KernelInterface to BuildDebugContainerTrait::getContainerBuilder()
This commit is contained in:
parent
cc29772236
commit
0e9652a4bc
@ -141,8 +141,9 @@ abstract class AbstractConfigCommand extends ContainerDebugCommand
|
|||||||
{
|
{
|
||||||
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
|
// Re-build bundle manually to initialize DI extensions that can be extended by other bundles in their build() method
|
||||||
// as this method is not called when the container is loaded from the cache.
|
// as this method is not called when the container is loaded from the cache.
|
||||||
$container = $this->getContainerBuilder();
|
$kernel = $this->getApplication()->getKernel();
|
||||||
$bundles = $this->getApplication()->getKernel()->getBundles();
|
$container = $this->getContainerBuilder($kernel);
|
||||||
|
$bundles = $kernel->getBundles();
|
||||||
foreach ($bundles as $bundle) {
|
foreach ($bundles as $bundle) {
|
||||||
if ($extension = $bundle->getContainerExtension()) {
|
if ($extension = $bundle->getContainerExtension()) {
|
||||||
$container->registerExtension($extension);
|
$container->registerExtension($extension);
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Config\FileLocator;
|
|||||||
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
|
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -32,14 +33,12 @@ trait BuildDebugContainerTrait
|
|||||||
*
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
protected function getContainerBuilder(): ContainerBuilder
|
protected function getContainerBuilder(KernelInterface $kernel): ContainerBuilder
|
||||||
{
|
{
|
||||||
if ($this->containerBuilder) {
|
if ($this->containerBuilder) {
|
||||||
return $this->containerBuilder;
|
return $this->containerBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = $this->getApplication()->getKernel();
|
|
||||||
|
|
||||||
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
|
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
|
||||||
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
|
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
|
||||||
$container = $buildContainer();
|
$container = $buildContainer();
|
||||||
|
@ -108,7 +108,7 @@ EOF
|
|||||||
if ($extension instanceof ConfigurationInterface) {
|
if ($extension instanceof ConfigurationInterface) {
|
||||||
$configuration = $extension;
|
$configuration = $extension;
|
||||||
} else {
|
} else {
|
||||||
$configuration = $extension->getConfiguration([], $this->getContainerBuilder());
|
$configuration = $extension->getConfiguration([], $this->getContainerBuilder($this->getApplication()->getKernel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validateConfiguration($extension, $configuration);
|
$this->validateConfiguration($extension, $configuration);
|
||||||
|
@ -123,7 +123,8 @@ EOF
|
|||||||
$errorIo = $io->getErrorStyle();
|
$errorIo = $io->getErrorStyle();
|
||||||
|
|
||||||
$this->validateInput($input);
|
$this->validateInput($input);
|
||||||
$object = $this->getContainerBuilder();
|
$kernel = $this->getApplication()->getKernel();
|
||||||
|
$object = $this->getContainerBuilder($kernel);
|
||||||
|
|
||||||
if ($input->getOption('env-vars')) {
|
if ($input->getOption('env-vars')) {
|
||||||
$options = ['env-vars' => true];
|
$options = ['env-vars' => true];
|
||||||
@ -160,12 +161,12 @@ EOF
|
|||||||
$options['show_hidden'] = $input->getOption('show-hidden');
|
$options['show_hidden'] = $input->getOption('show-hidden');
|
||||||
$options['raw_text'] = $input->getOption('raw');
|
$options['raw_text'] = $input->getOption('raw');
|
||||||
$options['output'] = $io;
|
$options['output'] = $io;
|
||||||
$options['is_debug'] = $this->getApplication()->getKernel()->isDebug();
|
$options['is_debug'] = $kernel->isDebug();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$helper->describe($io, $object, $options);
|
$helper->describe($io, $object, $options);
|
||||||
|
|
||||||
if (isset($options['id']) && isset($this->getApplication()->getKernel()->getContainer()->getRemovedIds()[$options['id']])) {
|
if (isset($options['id']) && isset($kernel->getContainer()->getRemovedIds()[$options['id']])) {
|
||||||
$errorIo->note(sprintf('The "%s" service or alias has been removed or inlined when the container was compiled.', $options['id']));
|
$errorIo->note(sprintf('The "%s" service or alias has been removed or inlined when the container was compiled.', $options['id']));
|
||||||
}
|
}
|
||||||
} catch (ServiceNotFoundException $e) {
|
} catch (ServiceNotFoundException $e) {
|
||||||
|
@ -76,7 +76,7 @@ EOF
|
|||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
$errorIo = $io->getErrorStyle();
|
$errorIo = $io->getErrorStyle();
|
||||||
|
|
||||||
$builder = $this->getContainerBuilder();
|
$builder = $this->getContainerBuilder($this->getApplication()->getKernel());
|
||||||
$serviceIds = $builder->getServiceIds();
|
$serviceIds = $builder->getServiceIds();
|
||||||
$serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']);
|
$serviceIds = array_filter($serviceIds, [$this, 'filterToServiceTypes']);
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ EOF
|
|||||||
private function getFileLink(string $class): string
|
private function getFileLink(string $class): string
|
||||||
{
|
{
|
||||||
if (null === $this->fileLinkFormatter
|
if (null === $this->fileLinkFormatter
|
||||||
|| (null === $r = $this->getContainerBuilder()->getReflectionClass($class, false))) {
|
|| (null === $r = $this->getContainerBuilder($this->getApplication()->getKernel())->getReflectionClass($class, false))) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,12 @@ EOF
|
|||||||
$name = $input->getArgument('name');
|
$name = $input->getArgument('name');
|
||||||
$helper = new DescriptorHelper($this->fileLinkFormatter);
|
$helper = new DescriptorHelper($this->fileLinkFormatter);
|
||||||
$routes = $this->router->getRouteCollection();
|
$routes = $this->router->getRouteCollection();
|
||||||
$container = $this->fileLinkFormatter ? \Closure::fromCallable([$this, 'getContainerBuilder']) : null;
|
$container = null;
|
||||||
|
if ($this->fileLinkFormatter) {
|
||||||
|
$container = function () {
|
||||||
|
return $this->getContainerBuilder($this->getApplication()->getKernel());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if ($name) {
|
if ($name) {
|
||||||
if (!($route = $routes->get($name)) && $matchingRoutes = $this->findRouteNameContaining($name, $routes)) {
|
if (!($route = $routes->get($name)) && $matchingRoutes = $this->findRouteNameContaining($name, $routes)) {
|
||||||
|
Reference in New Issue
Block a user