diff --git a/DependencyInjection/VichUploaderExtension.php b/DependencyInjection/VichUploaderExtension.php index d9de500a..cf317382 100644 --- a/DependencyInjection/VichUploaderExtension.php +++ b/DependencyInjection/VichUploaderExtension.php @@ -216,7 +216,7 @@ private function registerFormTheme(ContainerBuilder $container) $resources = $container->hasParameter('twig.form.resources') ? $container->getParameter('twig.form.resources') : []; - $resources[] = '@VichUploader/Form/fields.html.twig'; + array_unshift($resources, '@VichUploader/Form/fields.html.twig'); $container->setParameter('twig.form.resources', $resources); } } diff --git a/Resources/doc/usage.md b/Resources/doc/usage.md index 9037654d..e0a6d208 100644 --- a/Resources/doc/usage.md +++ b/Resources/doc/usage.md @@ -71,7 +71,7 @@ The `UploadableField` annotation has a few options. They are as follows: * `fileNameProperty`: required, the property that will contain the name of the uploaded file; * `size`: the property that will contain the size in bytes of the uploaded file; * `mimeType`: the property that will contain the mime type of the uploaded file; - * `originalName`: the property that will contain the origilal name of the uploaded file. + * `originalName`: the property that will contain the original name of the uploaded file. **Note**: diff --git a/Tests/DependencyInjection/VichUploaderExtensionTest.php b/Tests/DependencyInjection/VichUploaderExtensionTest.php index 0aeb223e..cc62c7d7 100644 --- a/Tests/DependencyInjection/VichUploaderExtensionTest.php +++ b/Tests/DependencyInjection/VichUploaderExtensionTest.php @@ -3,6 +3,7 @@ namespace Vich\UploaderBundle\Tests\DependencyInjection; use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; +use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension; use Vich\UploaderBundle\DependencyInjection\VichUploaderExtension; class VichUploaderExtensionTest extends AbstractExtensionTestCase @@ -26,6 +27,8 @@ protected function setUp() parent::setUp(); $this->container->setParameter('kernel.bundles', []); + $this->container->setParameter('kernel.bundles_metadata', []); + $this->container->setParameter('kernel.root_dir', __DIR__.'/../Fixtures/App/app'); $this->container->setParameter('kernel.cache_dir', sys_get_temp_dir()); } @@ -80,7 +83,7 @@ public function testMappingsServiceParameterIsSet() $this->assertContainerBuilderHasParameter('vich_uploader.mappings', $mappings); } - public function testDbDriverIsntOverriden() + public function testDbDriverIsNotOverridden() { $this->load([ 'db_driver' => 'propel', @@ -122,4 +125,21 @@ public function testListenersCreation() $this->assertContainerBuilderNotHasService('vich_uploader.listener.clean.profile_common_avatar'); $this->assertContainerBuilderHasService('vich_uploader.listener.remove.profile_common_avatar'); } + + public function testFormThemeCorrectlyOverridden() + { + $vichUploaderExtension = new VichUploaderExtension(); + $this->container->registerExtension($vichUploaderExtension); + + $twigExtension = new TwigExtension(); + $this->container->registerExtension($twigExtension); + + $twigExtension->load([['form_themes' => ['@Ololo/trololo.html.twig']]], $this->container); + $vichUploaderExtension->load([$this->getMinimalConfiguration()], $this->container); + + $this->assertContainerBuilderHasParameter( + 'twig.form.resources', + ['@VichUploader/Form/fields.html.twig', 'form_div_layout.html.twig', '@Ololo/trololo.html.twig'] + ); + } }