FilesystemLoader example

$template = $twig->loadTemplate($twig->getTemplateClass('storefront/frontend/dynamic_include.html.twig'), 'storefront/frontend/dynamic_include.html.twig');
        static::assertSame('a/TestPlugin1_a/TestPlugin2_a', $template->render(['child' => 'a']));
        static::assertSame('b/TestPlugin1_b/TestPlugin2_b', $template->render(['child' => 'b']));
    }

    /** * @param BundleFixture[] $bundles */
    private function initTwig(array $bundles): Environment
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $twig = new TwigEnvironment($loader['cache' => false]);

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            
new ProfileSalutationMissingError($customer),
            new BillingAddressSalutationMissingError($address),
            new ShippingAddressSalutationMissingError($address),
        ];
    }

    /** * @param array<BundleFixture> $bundles */
    private function createFinder(array $bundles): Environment
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        /** @var BundleFixture $bundle */
        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $twig = new Environment($loader['cache' => $this->cache]);

        $kernel = $this->createMock(Kernel::class);
        
$template->render([])
        );
    }

    /** * @param BundleFixture[] $bundles * * @return array{0: Environment, 1: TemplateFinder} */
    private function createFinder(array $bundles): array
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
        }

        $twig = new Environment($loader['cache' => $this->cache]);

        $kernel = $this->createMock(Kernel::class);
        $kernel->expects(static::any())
            
$this->setUpFixtures();
        $featureFlags = array_merge($featureFlags$this->fixtureFlags);

        $configAfterRegistration = array_keys(Feature::getAll(false));
        static::assertEquals(\array_map(Feature::normalizeName(...)$featureFlags), \array_map(Feature::normalizeName(...)$configAfterRegistration));
    }

    public function testTwigFeatureFlag(): void
    {
        $this->setUpFixtures();
        $loader = new FilesystemLoader(__DIR__ . '/_fixture/');
        $twig = new Environment($loader[
            'cache' => false,
        ]);
        $twig->addExtension(new FeatureFlagExtension());
        $template = $twig->loadTemplate($twig->getTemplateClass('featuretest.html.twig'), 'featuretest.html.twig');
        $_SERVER['FEATURE_NEXT_101'] = '1';
        static::assertSame('FeatureIsActive', $template->render([]));
        $_SERVER['FEATURE_NEXT_101'] = '0';
        static::assertSame('FeatureIsInactive', $template->render([]));
    }

    
$container->set(SeoUrlPlaceholderHandlerInterface::class$placeholder);

        return $container;
    }

    /** * @param Bundle[] $bundles */
    private function createFinder(array $bundles): Environment
    {
        $loader = new FilesystemLoader(__DIR__ . '/fixtures/Storefront/Resources/views');

        /** @var BundleFixture $bundle */
        foreach ($bundles as $bundle) {
            $directory = $bundle->getPath() . '/Resources/views';
            $loader->addPath($directory);
            $loader->addPath($directory$bundle->getName());
            if (file_exists($directory . '/../app/storefront/dist')) {
                $loader->addPath($directory . '/../app/storefront/dist', $bundle->getName());
            }
        }

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