mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-17 07:44:24 +00:00
67 lines
1.4 KiB
PHP
67 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\MainBundle\Templating;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\TwigFilter;
|
|
|
|
class TranslatableStringTwig extends AbstractExtension
|
|
{
|
|
use ContainerAwareTrait;
|
|
|
|
/**
|
|
* @var TranslatableStringHelper
|
|
*/
|
|
private $helper;
|
|
|
|
/**
|
|
* TranslatableStringTwig constructor.
|
|
*/
|
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
|
{
|
|
$this->helper = $translatableStringHelper;
|
|
}
|
|
|
|
/**
|
|
* Returns a list of filters to add to the existing list.
|
|
*
|
|
* (non-PHPdoc)
|
|
*
|
|
* @see Twig_Extension::getFilters()
|
|
*/
|
|
public function getFilters()
|
|
{
|
|
return [
|
|
new TwigFilter(
|
|
'localize_translatable_string',
|
|
[$this, 'localize']
|
|
), ];
|
|
}
|
|
|
|
/**
|
|
* Returns the name of the extension.
|
|
*
|
|
* @return The name of the extension.
|
|
*/
|
|
public function getName()
|
|
{
|
|
return 'chill_main_localize';
|
|
}
|
|
|
|
public function localize(array $translatableStrings)
|
|
{
|
|
return $this->helper
|
|
->localize($translatableStrings);
|
|
}
|
|
}
|