-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-88: Overridden Symfony debug:config command to use custom Contain…
…erBuilder
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Bundle\CompatibilityLayer\Command; | ||
|
||
use Ibexa\Bundle\CompatibilityLayer\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\ConfigCache; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder as SymfonyContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @see \Symfony\Bundle\FrameworkBundle\Command\BuildDebugContainerTrait | ||
*/ | ||
trait BuildDebugContainerTrait | ||
{ | ||
protected $containerBuilder; | ||
|
||
/** | ||
* Loads the ContainerBuilder from the cache. | ||
* | ||
* @throws \LogicException|\Exception | ||
*/ | ||
protected function getContainerBuilder(KernelInterface $kernel): SymfonyContainerBuilder | ||
{ | ||
if ($this->containerBuilder) { | ||
return $this->containerBuilder; | ||
} | ||
|
||
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) { | ||
$buildContainer = \Closure::bind(function () { | ||
$this->initializeBundles(); | ||
|
||
return $this->buildContainer(); | ||
}, $kernel, \get_class($kernel)); | ||
$container = $buildContainer(); | ||
$container->getCompilerPassConfig()->setRemovingPasses([]); | ||
$container->getCompilerPassConfig()->setAfterRemovingPasses([]); | ||
$container->compile(); | ||
} else { | ||
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump')); | ||
$locatorPass = new ServiceLocatorTagPass(); | ||
$locatorPass->process($container); | ||
} | ||
|
||
return $this->containerBuilder = $container; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Bundle\CompatibilityLayer\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ConfigDebugCommand; | ||
|
||
/** | ||
* @see \Symfony\Bundle\FrameworkBundle\Command\ConfigDebugCommand | ||
*/ | ||
class SymfonyConfigDebugCommand extends ConfigDebugCommand | ||
{ | ||
use BuildDebugContainerTrait; | ||
|
||
protected static $defaultName = 'debug:config'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters