mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,102 +1,97 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Chill\AMLI\FamilyMembersBundle\Templating;
|
||||
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Chill\AMLI\FamilyMembersBundle\Config\ConfigRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class Twig extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var ConfigRepository
|
||||
*/
|
||||
protected $configRepository;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
protected $translatableStringHelper;
|
||||
|
||||
|
||||
public function __construct(
|
||||
ConfigRepository $configRepository,
|
||||
ConfigRepository $configRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->configRepository = $configRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
|
||||
public function displayFamilialSituation($situation)
|
||||
{
|
||||
if (null === $situation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$this->configRepository->getFamilialSituationsLabels()[$situation]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayLink($link)
|
||||
{
|
||||
if (null === $link) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$this->configRepository->getLinksLabels()[$link]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayProfessionalSituation($situation)
|
||||
{
|
||||
if (null === $situation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$this->configRepository->getProfessionalSituationsLabels()[$situation]
|
||||
);
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
new TwigFilter('chill_family_member_link_display', [ $this, 'displayLink' ], [ 'is_safe' => [ 'html' ]]),
|
||||
new TwigFilter('chill_family_member_professional_situation_display', [ $this, 'displayProfessionalSituation' ], [ 'is_safe' => [ 'html' ]]),
|
||||
new TwigFilter('chill_family_member_familial_situation_display', [ $this, 'displayFamilialSituation' ], [ 'is_safe' => [ 'html' ]]),
|
||||
|
||||
new TwigFilter('chill_family_member_link_display', [$this, 'displayLink'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('chill_family_member_professional_situation_display', [$this, 'displayProfessionalSituation'], ['is_safe' => ['html']]),
|
||||
new TwigFilter('chill_family_member_familial_situation_display', [$this, 'displayFamilialSituation'], ['is_safe' => ['html']]),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('chill_family_members_has_professionnal_situation', [ $this, 'hasProfessionnalSituation' ]),
|
||||
new TwigFunction('chill_family_members_has_familial_situation', [ $this, 'hasFamilialSituation' ]),
|
||||
|
||||
new TwigFunction('chill_family_members_has_professionnal_situation', [$this, 'hasProfessionnalSituation']),
|
||||
new TwigFunction('chill_family_members_has_familial_situation', [$this, 'hasFamilialSituation']),
|
||||
];
|
||||
}
|
||||
|
||||
public function displayLink($link)
|
||||
{
|
||||
if (NULL === $link) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$this->configRepository->getLinksLabels()[$link]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayProfessionalSituation($situation)
|
||||
{
|
||||
if (NULL === $situation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$this->configRepository->getProfessionalSituationsLabels()[$situation]
|
||||
);
|
||||
}
|
||||
|
||||
public function hasProfessionnalSituation()
|
||||
{
|
||||
return $this->configRepository->hasProfessionalSituation();
|
||||
}
|
||||
|
||||
public function displayFamilialSituation($situation)
|
||||
{
|
||||
if (NULL === $situation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$this->configRepository->getFamilialSituationsLabels()[$situation]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function hasFamilialSituation()
|
||||
{
|
||||
return $this->configRepository->hasFamilialSituation();
|
||||
}
|
||||
|
||||
public function hasProfessionnalSituation()
|
||||
{
|
||||
return $this->configRepository->hasProfessionalSituation();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user