mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 23:46:12 +00:00
Remove templating.yaml, add interfaces.
This commit is contained in:
parent
5146419e9a
commit
c019da9bcf
@ -29,7 +29,7 @@ use Symfony\Component\Translation\Translator;
|
|||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class TranslatableStringHelper
|
class TranslatableStringHelper implements TranslatableStringHelperInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Templating;
|
||||||
|
|
||||||
|
interface TranslatableStringHelperInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* return the string in current locale if it exists.
|
||||||
|
*
|
||||||
|
* If it does not exists; return the name in the first language available.
|
||||||
|
*
|
||||||
|
* Return a blank string if any strings are available.
|
||||||
|
* Return NULL if $translatableString is NULL
|
||||||
|
*
|
||||||
|
* @param array $translatableStrings
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function localize(array $translatableStrings);
|
||||||
|
}
|
@ -10,6 +10,7 @@ services:
|
|||||||
- "@translator.default"
|
- "@translator.default"
|
||||||
|
|
||||||
Chill\MainBundle\Templating\TranslatableStringHelper: '@chill.main.helper.translatable_string'
|
Chill\MainBundle\Templating\TranslatableStringHelper: '@chill.main.helper.translatable_string'
|
||||||
|
Chill\MainBundle\Templating\TranslatableStringHelperInterface: Chill\MainBundle\Templating\TranslatableStringHelper
|
||||||
|
|
||||||
chill.main.twig.translatable_string:
|
chill.main.twig.translatable_string:
|
||||||
class: Chill\MainBundle\Templating\TranslatableStringTwig
|
class: Chill\MainBundle\Templating\TranslatableStringTwig
|
||||||
|
@ -46,6 +46,11 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: kernel.event_subscriber }
|
- { name: kernel.event_subscriber }
|
||||||
|
|
||||||
|
Chill\PersonBundle\Templating\Entity\:
|
||||||
|
resource: '../src/Templating/Entity/'
|
||||||
|
tags:
|
||||||
|
- { name: chill.render_entity }
|
||||||
|
|
||||||
chill.person.security.authorization.person:
|
chill.person.security.authorization.person:
|
||||||
class: Chill\PersonBundle\Security\Authorization\PersonVoter
|
class: Chill\PersonBundle\Security\Authorization\PersonVoter
|
||||||
arguments:
|
arguments:
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
services:
|
|
||||||
Chill\PersonBundle\Templating\Entity\PersonRender:
|
|
||||||
arguments:
|
|
||||||
$configAltNamesHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper'
|
|
||||||
tags:
|
|
||||||
- 'chill.render_entity'
|
|
||||||
|
|
||||||
Chill\PersonBundle\Templating\Entity\ClosingMotiveRender:
|
|
||||||
arguments:
|
|
||||||
$translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
|
|
||||||
tags:
|
|
||||||
- 'chill.render_entity'
|
|
@ -8,7 +8,7 @@ namespace Chill\PersonBundle\Config;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class ConfigPersonAltNamesHelper
|
class ConfigPersonAltNamesHelper implements ConfigPersonAltNamesHelperInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* the raw config, directly from the container parameter
|
* the raw config, directly from the container parameter
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Config;
|
||||||
|
|
||||||
|
interface ConfigPersonAltNamesHelperInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Return true if at least one alt name is configured
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasAltNames(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the choices as key => values
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getChoices(): array;
|
||||||
|
}
|
@ -68,7 +68,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
$loader->load('services/search.yaml');
|
$loader->load('services/search.yaml');
|
||||||
$loader->load('services/command.yaml');
|
$loader->load('services/command.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
|
||||||
$loader->load('services/alt_names.yaml');
|
$loader->load('services/alt_names.yaml');
|
||||||
$loader->load('services/serializer.yaml');
|
$loader->load('services/serializer.yaml');
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ namespace Chill\PersonBundle\Templating\Entity;
|
|||||||
|
|
||||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render closing motive
|
* Render closing motive
|
||||||
@ -15,12 +15,11 @@ class ClosingMotiveRender extends AbstractChillEntityRender
|
|||||||
private CONST SEPARATOR = ' > ';
|
private CONST SEPARATOR = ' > ';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @var TranslatableStringHelperInterface
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
*/
|
||||||
private $translatableStringHelper;
|
private $translatableStringHelper;
|
||||||
|
|
||||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
public function __construct(TranslatableStringHelperInterface $translatableStringHelper)
|
||||||
{
|
{
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace Chill\PersonBundle\Templating\Entity;
|
|||||||
|
|
||||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelperInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a Person
|
* Render a Person
|
||||||
@ -32,11 +32,11 @@ class PersonRender extends AbstractChillEntityRender
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var ConfigPersonAltNamesHelper
|
* @var ConfigPersonAltNamesHelperInterface
|
||||||
*/
|
*/
|
||||||
protected $configAltNamesHelper;
|
protected $configAltNamesHelper;
|
||||||
|
|
||||||
public function __construct(ConfigPersonAltNamesHelper $configAltNamesHelper)
|
public function __construct(ConfigPersonAltNamesHelperInterface $configAltNamesHelper)
|
||||||
{
|
{
|
||||||
$this->configAltNamesHelper = $configAltNamesHelper;
|
$this->configAltNamesHelper = $configAltNamesHelper;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user