Skip to content

Commit 59dbe63

Browse files
committed
bug #67 [Dropzone] Fix prepend twig extension (Jibbarth, weaverryan)
This PR was merged into the main branch. Discussion ---------- [Dropzone] Fix prepend twig extension | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Tickets | Fix #66 | License | MIT Hi 👋 Just prepend the form_themes needed instead of full configuration should fix issue #66 BTW, I'm not sure how to add tests on this. Any clue ? Thanks 🤗 Commits ------- 1946e2f Adding failing test case for prepend bug fix a2e22fc [Dropzone] Fix prepend twig extension
2 parents 92e38c0 + 1946e2f commit 59dbe63

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

src/Dropzone/DependencyInjection/DropzoneExtension.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\UX\Dropzone\DependencyInjection;
1313

14-
use Symfony\Bundle\TwigBundle\DependencyInjection\Configuration;
1514
use Symfony\Component\DependencyInjection\ContainerBuilder;
1615
use Symfony\Component\DependencyInjection\Definition;
1716
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
@@ -34,10 +33,7 @@ public function prepend(ContainerBuilder $container)
3433
return;
3534
}
3635

37-
$config = $this->processConfiguration(new Configuration(), $container->getExtensionConfig('twig'));
38-
$config['form_themes'][] = '@Dropzone/form_theme.html.twig';
39-
40-
$container->prependExtensionConfig('twig', $config);
36+
$container->prependExtensionConfig('twig', ['form_themes' => ['@Dropzone/form_theme.html.twig']]);
4137
}
4238

4339
public function load(array $configs, ContainerBuilder $container)

src/Dropzone/Tests/DropzoneBundleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,15 @@ public function testBootKernel(Kernel $kernel)
3939
$kernel->boot();
4040
$this->assertArrayHasKey('DropzoneBundle', $kernel->getBundles());
4141
}
42+
43+
public function testFormThemeMerging()
44+
{
45+
$kernel = new TwigAppKernel('test', true);
46+
$kernel->boot();
47+
$this->assertEquals([
48+
'form_div_layout.html.twig',
49+
'@Dropzone/form_theme.html.twig',
50+
'form_theme.html.twig',
51+
], $kernel->getContainer()->getParameter('twig.form.resources'));
52+
}
4253
}

src/Dropzone/Tests/Kernel/TwigAppKernel.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ public function registerContainerConfiguration(LoaderInterface $loader)
3636
{
3737
$loader->load(function (ContainerBuilder $container) {
3838
$container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true]);
39-
$container->loadFromExtension('twig', ['default_path' => __DIR__.'/templates', 'strict_variables' => true, 'exception_controller' => null]);
39+
$container->loadFromExtension('twig', [
40+
'default_path' => __DIR__.'/templates',
41+
'strict_variables' => true,
42+
'form_themes' => [
43+
'form_theme.html.twig',
44+
],
45+
'exception_controller' => null,
46+
'debug' => '%kernel.debug%',
47+
]);
4048
});
4149
}
4250
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{# dummy file #}

0 commit comments

Comments
 (0)