Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

IOConfigurationPass.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler;
8
9 use ArrayObject;
10 use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
11 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
13 use Symfony\Component\DependencyInjection\ContainerBuilder;
14 use Symfony\Component\DependencyInjection\Definition;
15 use Symfony\Component\DependencyInjection\DefinitionDecorator;
16
22 class IOConfigurationPass implements CompilerPassInterface
23 {
25 private $metadataHandlerFactories;
26
28 private $binarydataHandlerFactories;
29
30 public function __construct(
31 ArrayObject $metadataHandlerFactories = null,
32 ArrayObject $binarydataHandlerFactories = null
33 ) {
34 $this->metadataHandlerFactories = $metadataHandlerFactories;
35 $this->binarydataHandlerFactories = $binarydataHandlerFactories;
36 }
37
43 public function process(ContainerBuilder $container)
44 {
45 $ioMetadataHandlers = $container->hasParameter('ez_io.metadata_handlers') ?
46 $container->getParameter('ez_io.metadata_handlers') :
47 [];
48 $this->processHandlers(
49 $container,
50 $container->getDefinition('ezpublish.core.io.metadata_handler.factory'),
51 $ioMetadataHandlers,
52 $this->metadataHandlerFactories,
53 'ezpublish.core.io.metadata_handler.flysystem.default'
54 );
55
56 $ioBinarydataHandlers = $container->hasParameter('ez_io.binarydata_handlers') ?
57 $container->getParameter('ez_io.binarydata_handlers') :
58 [];
59 $this->processHandlers(
60 $container,
61 $container->getDefinition('ezpublish.core.io.binarydata_handler.factory'),
62 $ioBinarydataHandlers,
63 $this->binarydataHandlerFactories,
64 'ezpublish.core.io.binarydata_handler.flysystem.default'
65 );
66
67 // Unset parameters that are no longer required ?
68 }
69
79 protected function processHandlers(
80 ContainerBuilder $container,
81 Definition $factory,
82 array $configuredHandlers,
83 ArrayObject $factories,
84 $defaultHandler
85 ) {
86 $handlers = ['default' => $defaultHandler];
87
88 foreach ($configuredHandlers as $name => $config) {
89 $configurationFactory = $this->getFactory($factories, $config['type'], $container);
90
91 $parentHandlerId = $configurationFactory->getParentServiceId();
92 $handlerId = sprintf('%s.%s', $parentHandlerId, $name);
93 $definition = $container->setDefinition($handlerId, new DefinitionDecorator($parentHandlerId));
94
95 $configurationFactory->configureHandler($definition, $config);
96
97 $handlers[$name] = $handlerId;
98 }
99
100 $factory->addMethodCall('setHandlersMap', [$handlers]);
101 }
102
112 protected function getFactory(ArrayObject $factories, $type, ContainerBuilder $container)
113 {
114 if (!isset($factories[$type])) {
115 throw new InvalidConfigurationException("Unknown handler type $type");
116 }
117 if ($factories[$type] instanceof ContainerAwareInterface) {
118 $factories[$type]->setContainer($container);
119 }
120
121 return $factories[$type];
122 }
123 }
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass
This compiler pass will create the metadata and binarydata IO handlers depending on container configu...
Definition: IOConfigurationPass.php:23
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass\getFactory
getFactory(ArrayObject $factories, $type, ContainerBuilder $container)
Returns from $factories the factory for handler $type.
Definition: IOConfigurationPass.php:112
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass\$metadataHandlerFactories
$metadataHandlerFactories
Definition: IOConfigurationPass.php:25
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass\process
process(ContainerBuilder $container)
Definition: IOConfigurationPass.php:43
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass\__construct
__construct(ArrayObject $metadataHandlerFactories=null, ArrayObject $binarydataHandlerFactories=null)
Definition: IOConfigurationPass.php:30
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass\processHandlers
processHandlers(ContainerBuilder $container, Definition $factory, array $configuredHandlers, ArrayObject $factories, $defaultHandler)
Definition: IOConfigurationPass.php:79
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler\IOConfigurationPass\$binarydataHandlerFactories
$binarydataHandlerFactories
Definition: IOConfigurationPass.php:28
eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler
Definition: IOConfigurationPass.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.