compileContainer example



    // If the module list hasn't already been set in updateModules and we are     // not forcing a rebuild, then try and load the container from the cache.     if (empty($this->moduleList) && !$this->containerNeedsRebuild) {
      $container_definition = $this->getCachedContainerDefinition();
    }

    // If there is no container and no cached container definition, build a new     // one from scratch.     if (!isset($container) && !isset($container_definition)) {
      $container = $this->compileContainer();

      // Only dump the container if dumping is allowed. This is useful for       // KernelTestBase, which never wants to use the real container, but always       // the container builder.       if ($this->allowDumping) {
        $dumper = new $this->phpArrayDumperClass($container);
        $container_definition = $dumper->getArray();
      }
    }

    // The container was rebuilt successfully.
$this->listBundles($errorIo);
            $this->listNonBundleExtensions($errorIo);

            $errorIo->comment('Provide the name of a bundle as the first argument of this command to dump its configuration. (e.g. <comment>debug:config FrameworkBundle</comment>)');
            $errorIo->comment('For dumping a specific option, add its path as the second argument of this command. (e.g. <comment>debug:config FrameworkBundle serializer</comment> to dump the <comment>framework.serializer</comment> configuration)');

            return 0;
        }

        $extension = $this->findExtension($name);
        $extensionAlias = $extension->getAlias();
        $container = $this->compileContainer();

        $config = $this->getConfig($extension$container$input->getOption('resolve-env'));

        $format = $input->getOption('format');

        if (\in_array($format['txt', 'yml'], true) && !class_exists(Yaml::class)) {
            $errorIo->error('Setting the "format" option to "txt" or "yaml" requires the Symfony Yaml component. Try running "composer install symfony/yaml" or use "--format=json" instead.');

            return 1;
        }

        
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Server\Connection;
use Symfony\Component\VarDumper\Server\DumpServer;

class DebugExtensionTest extends TestCase
{
    public function testLoadWithoutConfiguration()
    {
        $container = $this->createContainer();
        $container->registerExtension(new DebugExtension());
        $container->loadFromExtension('debug', []);
        $this->compileContainer($container);

        $expectedTags = [
            [
                'id' => 'dump',
                'template' => '@Debug/Profiler/dump.html.twig',
                'priority' => 240,
            ],
        ];

        $this->assertSame($expectedTags$container->getDefinition('data_collector.dump')->getTag('data_collector'));
    }

    
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Stopwatch\Stopwatch;
use Twig\Environment;

class TwigExtensionTest extends TestCase
{
    public function testLoadEmptyConfiguration()
    {
        $container = $this->createContainer();
        $container->registerExtension(new TwigExtension());
        $container->loadFromExtension('twig');
        $this->compileContainer($container);

        $this->assertEquals(Environment::class$container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file');

        $this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources'), '->load() includes default template for form resources');

        // Twig options         $options = $container->getDefinition('twig')->getArgument(1);
        $this->assertEquals('%kernel.cache_dir%/twig', $options['cache'], '->load() sets default value for cache option');
        $this->assertEquals('%kernel.charset%', $options['charset'], '->load() sets default value for charset option');
        $this->assertEquals('%kernel.debug%', $options['debug'], '->load() sets default value for debug option');

        
Home | Imprint | This part of the site doesn't use cookies.