"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core-bundle/src/DependencyInjection/Compiler/RegisterFragmentsPass.php" between
contao-4.9.11.tar.gz and contao-4.9.12.tar.gz

About: Contao (fka TYPOlight) is a content management system (CMS). Long-term support (LTS).

RegisterFragmentsPass.php  (contao-4.9.11):RegisterFragmentsPass.php  (contao-4.9.12)
skipping to change at line 52 skipping to change at line 52
/** /**
* @var string|null * @var string|null
*/ */
private $globalsKey; private $globalsKey;
/** /**
* @var string|null * @var string|null
*/ */
private $proxyClass; private $proxyClass;
public function __construct(string $tag = null, string $globalsKey = null, s /**
tring $proxyClass = null) * @var string|null
*/
private $templateOptionsListener;
public function __construct(string $tag = null, string $globalsKey = null, s
tring $proxyClass = null, string $templateOptionsListener = null)
{ {
if (null === $tag) { if (null === $tag) {
@trigger_error('Using "new RegisterFragmentsPass()" without passing the tag name has been deprecated and will no longer work in Contao 5.0.', E_USER _DEPRECATED); @trigger_error('Using "new RegisterFragmentsPass()" without passing the tag name has been deprecated and will no longer work in Contao 5.0.', E_USER _DEPRECATED);
} }
$this->tag = $tag; $this->tag = $tag;
$this->globalsKey = $globalsKey; $this->globalsKey = $globalsKey;
$this->proxyClass = $proxyClass; $this->proxyClass = $proxyClass;
$this->templateOptionsListener = $templateOptionsListener;
} }
/** /**
* Adds the fragments to the registry. * Adds the fragments to the registry.
*/ */
public function process(ContainerBuilder $container): void public function process(ContainerBuilder $container): void
{ {
if (!$this->tag || !$container->has('contao.fragment.registry')) { if (!$this->tag || !$container->has('contao.fragment.registry')) {
return; return;
} }
skipping to change at line 82 skipping to change at line 88
$this->registerFragments($container, $this->tag); $this->registerFragments($container, $this->tag);
} }
/** /**
* @throws InvalidConfigurationException * @throws InvalidConfigurationException
*/ */
protected function registerFragments(ContainerBuilder $container, string $ta g): void protected function registerFragments(ContainerBuilder $container, string $ta g): void
{ {
$globals = []; $globals = [];
$preHandlers = []; $preHandlers = [];
$templates = [];
$registry = $container->findDefinition('contao.fragment.registry'); $registry = $container->findDefinition('contao.fragment.registry');
$command = $container->hasDefinition('contao.command.debug_fragments') ? $container->findDefinition('contao.command.debug_fragments') : null; $command = $container->hasDefinition('contao.command.debug_fragments') ? $container->findDefinition('contao.command.debug_fragments') : null;
foreach ($this->findAndSortTaggedServices($tag, $container) as $referenc e) { foreach ($this->findAndSortTaggedServices($tag, $container) as $referenc e) {
// If a controller has multiple methods for different fragment types (e.g. a content // If a controller has multiple methods for different fragment types (e.g. a content
// element and a front end module), the first pass creates a child d efinition that // element and a front end module), the first pass creates a child d efinition that
// inherits all tags from the original. On the next run, the pass wo uld pick up the // inherits all tags from the original. On the next run, the pass wo uld pick up the
// child definition and try to create duplicate fragments. // child definition and try to create duplicate fragments.
if (0 === strpos((string) $reference, 'contao.fragment._')) { if (0 === strpos((string) $reference, 'contao.fragment._')) {
continue; continue;
skipping to change at line 111 skipping to change at line 118
$attributes['debugController'] = $this->getControllerName(new Re ference($definition->getClass()), $attributes); $attributes['debugController'] = $this->getControllerName(new Re ference($definition->getClass()), $attributes);
$identifier = sprintf('%s.%s', $tag, $attributes['type']); $identifier = sprintf('%s.%s', $tag, $attributes['type']);
$serviceId = 'contao.fragment._'.$identifier; $serviceId = 'contao.fragment._'.$identifier;
$childDefinition = new ChildDefinition((string) $reference); $childDefinition = new ChildDefinition((string) $reference);
$childDefinition->setPublic(true); $childDefinition->setPublic(true);
$config = $this->getFragmentConfig($container, new Reference($se rviceId), $attributes); $config = $this->getFragmentConfig($container, new Reference($se rviceId), $attributes);
if (!empty($attributes['template'])) {
$templates[$attributes['type']] = $attributes['template'];
}
if (is_a($definition->getClass(), FragmentPreHandlerInterface::c lass, true)) { if (is_a($definition->getClass(), FragmentPreHandlerInterface::c lass, true)) {
$preHandlers[$identifier] = new Reference($serviceId); $preHandlers[$identifier] = new Reference($serviceId);
} }
if (is_a($definition->getClass(), FragmentOptionsAwareInterface: :class, true)) { if (is_a($definition->getClass(), FragmentOptionsAwareInterface: :class, true)) {
$childDefinition->addMethodCall('setFragmentOptions', [$attr ibutes]); $childDefinition->addMethodCall('setFragmentOptions', [$attr ibutes]);
} }
$registry->addMethodCall('add', [$identifier, $config]); $registry->addMethodCall('add', [$identifier, $config]);
skipping to change at line 140 skipping to change at line 151
throw new InvalidConfigurationException(sprintf('Missing category for "%s" fragment on service ID "%s"', $tag, (string) $reference)); throw new InvalidConfigurationException(sprintf('Missing category for "%s" fragment on service ID "%s"', $tag, (string) $reference));
} }
$globals[$this->globalsKey][$attributes['category']][$attrib utes['type']] = $this->proxyClass; $globals[$this->globalsKey][$attributes['category']][$attrib utes['type']] = $this->proxyClass;
} }
} }
} }
$this->addPreHandlers($container, $preHandlers); $this->addPreHandlers($container, $preHandlers);
$this->addGlobalsMapListener($globals, $container); $this->addGlobalsMapListener($globals, $container);
if (null !== $this->templateOptionsListener && $container->hasDefinition
($this->templateOptionsListener)) {
$container->findDefinition($this->templateOptionsListener)->addMetho
dCall('setCustomTemplates', [$templates]);
}
} }
protected function getFragmentConfig(ContainerBuilder $container, Reference $reference, array $attributes): Reference protected function getFragmentConfig(ContainerBuilder $container, Reference $reference, array $attributes): Reference
{ {
$definition = new Definition( $definition = new Definition(
FragmentConfig::class, FragmentConfig::class,
[ [
$this->getControllerName($reference, $attributes), $this->getControllerName($reference, $attributes),
$attributes['renderer'] ?? 'forward', $attributes['renderer'] ?? 'forward',
array_merge(['ignore_errors' => false], $attributes['options'] ? ? []), array_merge(['ignore_errors' => false], $attributes['options'] ? ? []),
 End of changes. 5 change blocks. 
2 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)