From 4508606772a442271a0a315d480ff255536b5ce6 Mon Sep 17 00:00:00 2001 From: Hannes Giesenow Date: Thu, 25 Jul 2024 09:41:23 +0200 Subject: [PATCH] Fix: User default twig namespace to easily override --- config/ezplatform.yaml | 4 ++-- src/DependencyInjection/ElbformatIconExtension.php | 3 --- src/Form/Type/IconType.php | 2 +- templates/icon_field.html.twig | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/config/ezplatform.yaml b/config/ezplatform.yaml index 04f6406..c04684f 100644 --- a/config/ezplatform.yaml +++ b/config/ezplatform.yaml @@ -2,6 +2,6 @@ ezplatform: system: default: field_templates: - - { template: '@ElbformatIconFieldtype/icon_field.html.twig', priority: 0 } + - { template: '@ElbformatIcon/icon_field.html.twig', priority: 0 } fielddefinition_edit_templates: - - { template: '@ElbformatIconFieldtype/icon_field_type_definition.html.twig', priority: 0 } \ No newline at end of file + - { template: '@ElbformatIcon/icon_field_type_definition.html.twig', priority: 0 } \ No newline at end of file diff --git a/src/DependencyInjection/ElbformatIconExtension.php b/src/DependencyInjection/ElbformatIconExtension.php index 3f29f0a..b65c3c7 100644 --- a/src/DependencyInjection/ElbformatIconExtension.php +++ b/src/DependencyInjection/ElbformatIconExtension.php @@ -38,9 +38,6 @@ public function prepend(ContainerBuilder $container): void $config = Yaml::parse($configFile); $container->prependExtensionConfig('ezpublish', $config['ezplatform']); - // Register namespace (as this is not done automatically. Maybe the missing "bundle" in path?) - $container->prependExtensionConfig('twig', ['paths' => [__DIR__.'/../../templates' => 'ElbformatIconFieldtype']]); - // Register translations (as this is not done automatically. Maybe the missing "bundle" in path?) $container->prependExtensionConfig('framework', ['translator' => ['paths' => [__DIR__.'/../../translations']]]); diff --git a/src/Form/Type/IconType.php b/src/Form/Type/IconType.php index d6f9e7f..97936c3 100644 --- a/src/Form/Type/IconType.php +++ b/src/Form/Type/IconType.php @@ -28,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $iconList = $this->iconSetManager->getSet($iconSet)->getList(); $iconTemplates = []; foreach($iconList as $icon) { - $iconTemplates[$icon] = $this->twig->render('@ElbformatIconFieldtype/icon.html.twig', ['icon' => $icon,'iconset' => $iconSet]); + $iconTemplates[$icon] = $this->twig->render('@ElbformatIcon/icon.html.twig', ['icon' => $icon,'iconset' => $iconSet]); } $builder->add('icon', ChoiceType::class, [ 'choices' => $iconList, diff --git a/templates/icon_field.html.twig b/templates/icon_field.html.twig index c7dadab..46c7e7c 100644 --- a/templates/icon_field.html.twig +++ b/templates/icon_field.html.twig @@ -1,7 +1,7 @@ {% block icon_field %}
- {{ include('@ElbformatIconFieldtype/icon.html.twig', { + {{ include('@ElbformatIcon/icon.html.twig', { icon: field.value.icon, iconset: fieldSettings.iconset }, with_context=false) }}