Removed not used {trans} twig token

This commit is contained in:
Igor Scheller 2019-11-29 16:51:36 +01:00
parent a1e1d91a64
commit f8e1f85089
3 changed files with 4 additions and 41 deletions

View File

@ -40,7 +40,6 @@
"swiftmailer/swiftmailer": "^6.2", "swiftmailer/swiftmailer": "^6.2",
"symfony/http-foundation": "^4.3", "symfony/http-foundation": "^4.3",
"symfony/psr-http-message-bridge": "^1.2", "symfony/psr-http-message-bridge": "^1.2",
"twig/extensions": "^1.5",
"twig/twig": "~2.6.0", "twig/twig": "~2.6.0",
"vlucas/phpdotenv": "^3.3" "vlucas/phpdotenv": "^3.3"
}, },

View File

@ -4,27 +4,20 @@ namespace Engelsystem\Renderer\Twig\Extensions;
use Engelsystem\Helpers\Translation\Translator; use Engelsystem\Helpers\Translation\Translator;
use Twig_Extension as TwigExtension; use Twig_Extension as TwigExtension;
use Twig_Extensions_TokenParser_Trans as TranslationTokenParser;
use Twig_Filter as TwigFilter; use Twig_Filter as TwigFilter;
use Twig_Function as TwigFunction; use Twig_Function as TwigFunction;
use Twig_TokenParserInterface as TwigTokenParser;
class Translation extends TwigExtension class Translation extends TwigExtension
{ {
/** @var Translator */ /** @var Translator */
protected $translator; protected $translator;
/** @var TranslationTokenParser */
protected $tokenParser;
/** /**
* @param Translator $translator * @param Translator $translator
* @param TranslationTokenParser $tokenParser
*/ */
public function __construct(Translator $translator, TranslationTokenParser $tokenParser) public function __construct(Translator $translator)
{ {
$this->translator = $translator; $this->translator = $translator;
$this->tokenParser = $tokenParser;
} }
/** /**
@ -47,12 +40,4 @@ class Translation extends TwigExtension
new TwigFunction('_e', [$this->translator, 'translatePlural']), new TwigFunction('_e', [$this->translator, 'translatePlural']),
]; ];
} }
/**
* @return TwigTokenParser[]
*/
public function getTokenParsers()
{
return [$this->tokenParser];
}
} }

View File

@ -5,7 +5,6 @@ namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
use Engelsystem\Helpers\Translation\Translator; use Engelsystem\Helpers\Translation\Translator;
use Engelsystem\Renderer\Twig\Extensions\Translation; use Engelsystem\Renderer\Twig\Extensions\Translation;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Twig_Extensions_TokenParser_Trans as TranslationTokenParser;
class TranslationTest extends ExtensionTest class TranslationTest extends ExtensionTest
{ {
@ -17,10 +16,8 @@ class TranslationTest extends ExtensionTest
{ {
/** @var Translator|MockObject $translator */ /** @var Translator|MockObject $translator */
$translator = $this->createMock(Translator::class); $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(); $filters = $extension->getFilters();
$this->assertExtensionExists('trans', [$translator, 'translate'], $filters); $this->assertExtensionExists('trans', [$translator, 'translate'], $filters);
@ -33,29 +30,11 @@ class TranslationTest extends ExtensionTest
{ {
/** @var Translator|MockObject $translator */ /** @var Translator|MockObject $translator */
$translator = $this->createMock(Translator::class); $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(); $functions = $extension->getFunctions();
$this->assertExtensionExists('__', [$translator, 'translate'], $functions); $this->assertExtensionExists('__', [$translator, 'translate'], $functions);
$this->assertExtensionExists('_e', [$translator, 'translatePlural'], $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);
}
} }