Definition example


        $paths = $this->collectControllerPaths($this->plugins);
        if (\count($paths) === 0) {
            return;
        }

        $controllers = $this->getControllers($paths);
        if (\count($controllers) === 0) {
            return;
        }

        $listener = new Definition(ControllerPathListener::class);
        $listener->setPublic(true);

        foreach ($controllers as $eventName => $file) {
            $listener
                ->addTag(
                    'shopware.event_listener',
                    [
                        'event' => $eventName,
                        'method' => 'getControllerPath',
                        'priority' => 500,
                    ]
                )
private function registerFilesystems(ContainerBuilder $container): void
    {
        $this->registerFilesystem($container, 'private');
        $this->registerFilesystem($container, 'public');
    }

    private function registerFilesystem(ContainerBuilder $container, string $key): void
    {
        $parameterKey = sprintf('shopware.filesystem.%s', $key);
        $serviceId = sprintf('%s.filesystem.%s', $this->getContainerPrefix()$key);

        $filesystem = new Definition(
            PrefixFilesystem::class,
            [
                new Reference($parameterKey),
                'plugins/' . $this->getContainerPrefix(),
            ]
        );
        $filesystem->setPublic(true);

        $container->setDefinition($serviceId$filesystem);
    }
}
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ExpressionLanguage\Expression;

class RegisterTypeRepositories implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        /** @var array<string, array> $types */
        $types = $container->getParameter('shopware.bundle.content_type.types');

        foreach (array_keys($types) as $name) {
            $def = new Definition(Repository::class);

            $def->setArguments([
                new Reference('dbal_connection'),
                new Expression('service("Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\TypeProvider").getType("' . $name . '")'),
                new Reference('translation'),
                new Reference('shopware_storefront.context_service'),
                new Reference(TypeFieldResolver::class),
            ]);

            $def->setPublic(true);

            
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\ExpressionLanguage\Expression;

class RegisterDynamicController implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        /** @var array<string, array> $types */
        $types = $container->getParameter('shopware.bundle.content_type.types');

        foreach ($types as $name => $type) {
            $backendController = new Definition(ContentType::class);
            $backendController->setArguments([
                new Reference(\Shopware\Bundle\ContentTypeBundle\Services\ExtjsBuilderInterface::class),
                new Expression('service("Shopware\\\\Bundle\\\\ContentTypeBundle\\\\Services\\\\TypeProvider").getType("' . $name . '")'),
                new Reference('shopware.bundle.content_type.' . $name),
            ]);

            $backendController->addTag(
                'shopware.controller',
                [
                    'controller' => 'Custom' . ucfirst($name),
                    'module' => 'backend',
                ]
if (!$container->hasParameter($logMaxFiles = $this->getParameterNameLoggerMaxFiles($servicePrefix))) {
            $container->setParameter($logMaxFiles, 14);
        }

        $container->setDefinition($this->getServiceIdLoggerHandler($servicePrefix)$this->createLoggerHandler($servicePrefix));
        $container->setDefinition($this->getServiceIdLoggerFormatter($servicePrefix)$this->createLoggerFormatter());
        $container->setDefinition($this->getServiceIdLogger($servicePrefix)$this->createLogger($servicePrefix));
    }

    protected function createLoggerHandler(string $servicePrefix): Definition
    {
        return (new Definition(RotatingFileHandler::class[
                sprintf('%%kernel.logs_dir%%/%s_%%kernel.environment%%.log', $servicePrefix),
                sprintf('%%%s%%', $this->getParameterNameLoggerMaxFiles($servicePrefix)),
                sprintf('%%%s%%', $this->getParameterNameLogLevel($servicePrefix)),
            ]))
            ->addMethodCall('pushProcessor', [new Reference('monolog.processor.uid')])
            ->setPublic(false)
        ;
    }

    protected function createLoggerFormatter(): Definition
    {
        

    private $plugins;

    public function __construct(array $plugins)
    {
        $this->plugins = $plugins;
    }

    public function process(ContainerBuilder $container): void
    {
        foreach ($this->plugins as $plugin) {
            $definition = new Definition(Plugin\ResourceSubscriber::class);
            $definition->setPublic(true);
            $definition->setArguments([
                $plugin->getPath(),
            ]);

            if (is_dir($plugin->getPath() . '/Resources/frontend/css')) {
                $definition->addTag('shopware.event_listener', [
                    'event' => 'Theme_Compiler_Collect_Plugin_Css',
                    'method' => 'onCollectCss',
                ]);
            }

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