FileLocator example

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class ControllerBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}


        $container->addCompilerPass(new BusinessEventRegisterCompilerPass($classes), PassConfig::TYPE_BEFORE_OPTIMIZATION, 0);
    }

    /** * Looks for service definition files inside the `Resources/config` * directory and loads either xml or yml files. */
    private function registerContainerFile(ContainerBuilder $container): void
    {
        $fileLocator = new FileLocator($this->getPath());
        $loaderResolver = new LoaderResolver([
            new XmlFileLoader($container$fileLocator),
            new YamlFileLoader($container$fileLocator),
            new PhpFileLoader($container$fileLocator),
        ]);
        $delegatingLoader = new DelegatingLoader($loaderResolver);

        foreach ($this->getServicesFilePathArray($this->getPath() . '/Resources/config/services.*') as $path) {
            $delegatingLoader->load($path);
        }

        
return $this->camelCaseToUnderscore($this->getName());
    }

    final protected function loadFiles(ContainerBuilder $container): void
    {
        if (!is_file($this->getPath() . '/Resources/services.xml')) {
            return;
        }

        $loader = new XmlFileLoader(
            $container,
            new FileLocator()
        );

        $loader->load($this->getPath() . '/Resources/services.xml');
    }

    private function camelCaseToUnderscore(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($string);
    }

    private function registerFilesystems(ContainerBuilder $container): void
    {

#[Package('core')] class Maintenance extends Bundle
{
    /** * {@inheritdoc} */
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class SitemapBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $container->addCompilerPass(new SitemapCompilerPass());

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class SearchBundleES extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class StaticContentBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class CustomerSearchBundleDBALBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class FormBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}


    /** * Prepares the ContainerBuilder before it is compiled. * * @param ContainerBuilder $container A ContainerBuilder instance * * @throws Exception */
    protected function prepareContainer(ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/Components/DependencyInjection/'));
        $loader->load('services.xml');
        $loader->load('theme.xml');
        $loader->load('logger.xml');
        $loader->load('commands.xml');

        if (is_file($file = __DIR__ . '/Components/DependencyInjection/services_local.xml')) {
            $loader->load($file);
        }

        $this->addShopwareConfig($container, 'shopware', $this->config);
        $this->addResources($container);

        

#[Package('storefront')] class Storefront extends Bundle implements ThemeInterface
{
    /** * {@inheritdoc} */
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
        $loader->load('seo.xml');
        $loader->load('controller.xml');
        $loader->load('theme.xml');

        /** @var string $environment */
        $environment = $container->getParameter('kernel.environment');

        $this->buildConfig($container$environment);

        $container->setParameter('storefrontRoot', $this->getPath());

        

    public function build(ContainerBuilder $container): void
    {
        /** @var string $environment */
        $environment = $container->getParameter('kernel.environment');

        parent::build($container);

        $this->buildConfig($container$environment);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection/'));
        $loader->load('services.xml');

        if ($environment === 'dev') {
            $loader->load('services_dev.xml');
        }

        $container->addCompilerPass(new RemoveDevServices());
    }

    public function boot(): void
    {
        
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AccountBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}

#[Package('core')] class DevOps extends Bundle
{
    /** * {@inheritdoc} */
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');

        $environment = $container->getParameter('kernel.environment');
        if ($environment === 'e2e') {
            $loader->load('services_e2e.xml');
        }
    }
}
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class StoreFrontBundle extends Bundle
{
    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
    }
}
Home | Imprint | This part of the site doesn't use cookies.