From f8e1f8508957dfb2f4db1485f3e17358f9a72a31 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Fri, 29 Nov 2019 16:51:36 +0100 Subject: [PATCH] Removed not used {trans} twig token --- composer.json | 1 - src/Renderer/Twig/Extensions/Translation.php | 19 ++------------ .../Twig/Extensions/TranslationTest.php | 25 ++----------------- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index d76abe94..9f56bab7 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,6 @@ "swiftmailer/swiftmailer": "^6.2", "symfony/http-foundation": "^4.3", "symfony/psr-http-message-bridge": "^1.2", - "twig/extensions": "^1.5", "twig/twig": "~2.6.0", "vlucas/phpdotenv": "^3.3" }, diff --git a/src/Renderer/Twig/Extensions/Translation.php b/src/Renderer/Twig/Extensions/Translation.php index 3e6f30b4..929310a1 100644 --- a/src/Renderer/Twig/Extensions/Translation.php +++ b/src/Renderer/Twig/Extensions/Translation.php @@ -4,27 +4,20 @@ namespace Engelsystem\Renderer\Twig\Extensions; use Engelsystem\Helpers\Translation\Translator; use Twig_Extension as TwigExtension; -use Twig_Extensions_TokenParser_Trans as TranslationTokenParser; use Twig_Filter as TwigFilter; use Twig_Function as TwigFunction; -use Twig_TokenParserInterface as TwigTokenParser; class Translation extends TwigExtension { /** @var Translator */ protected $translator; - /** @var TranslationTokenParser */ - protected $tokenParser; - /** - * @param Translator $translator - * @param TranslationTokenParser $tokenParser + * @param Translator $translator */ - public function __construct(Translator $translator, TranslationTokenParser $tokenParser) + public function __construct(Translator $translator) { $this->translator = $translator; - $this->tokenParser = $tokenParser; } /** @@ -47,12 +40,4 @@ class Translation extends TwigExtension new TwigFunction('_e', [$this->translator, 'translatePlural']), ]; } - - /** - * @return TwigTokenParser[] - */ - public function getTokenParsers() - { - return [$this->tokenParser]; - } } diff --git a/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php b/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php index 0b055c44..3b4b05c6 100644 --- a/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php +++ b/tests/Unit/Renderer/Twig/Extensions/TranslationTest.php @@ -5,7 +5,6 @@ namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions; use Engelsystem\Helpers\Translation\Translator; use Engelsystem\Renderer\Twig\Extensions\Translation; use PHPUnit\Framework\MockObject\MockObject; -use Twig_Extensions_TokenParser_Trans as TranslationTokenParser; class TranslationTest extends ExtensionTest { @@ -17,10 +16,8 @@ class TranslationTest extends ExtensionTest { /** @var Translator|MockObject $translator */ $translator = $this->createMock(Translator::class); - /** @var TranslationTokenParser|MockObject $parser */ - $parser = $this->createMock(TranslationTokenParser::class); - $extension = new Translation($translator, $parser); + $extension = new Translation($translator); $filters = $extension->getFilters(); $this->assertExtensionExists('trans', [$translator, 'translate'], $filters); @@ -33,29 +30,11 @@ class TranslationTest extends ExtensionTest { /** @var Translator|MockObject $translator */ $translator = $this->createMock(Translator::class); - /** @var TranslationTokenParser|MockObject $parser */ - $parser = $this->createMock(TranslationTokenParser::class); - $extension = new Translation($translator, $parser); + $extension = new Translation($translator); $functions = $extension->getFunctions(); $this->assertExtensionExists('__', [$translator, 'translate'], $functions); $this->assertExtensionExists('_e', [$translator, 'translatePlural'], $functions); } - - /** - * @covers \Engelsystem\Renderer\Twig\Extensions\Translation::getTokenParsers - */ - public function testGetTokenParsers() - { - /** @var Translator|MockObject $translator */ - $translator = $this->createMock(Translator::class); - /** @var TranslationTokenParser|MockObject $parser */ - $parser = $this->createMock(TranslationTokenParser::class); - - $extension = new Translation($translator, $parser); - $tokenParsers = $extension->getTokenParsers(); - - $this->assertTokenParserExists($parser, $tokenParsers); - } }