mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-09 23:09:43 +00:00
Change config logic and add condition within twig template
This commit is contained in:
@@ -120,6 +120,3 @@ chill_activity:
|
|||||||
-
|
-
|
||||||
label: '5 hours'
|
label: '5 hours'
|
||||||
seconds: 18000
|
seconds: 18000
|
||||||
|
|
||||||
chill_aside_activity:
|
|
||||||
show_concerned_persons_count: true
|
|
||||||
|
@@ -25,7 +25,7 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte
|
|||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
$container->setParameter('chill_aside_activity.form.time_duration', $config['form']['time_duration']);
|
$container->setParameter('chill_aside_activity.form.time_duration', $config['form']['time_duration']);
|
||||||
$container->setParameter('chill_aside_activity.show_concerned_persons_count', $config['show_concerned_persons_count']);
|
$container->setParameter('chill_aside_activity.show_concerned_persons_count', $config['show_concerned_persons_count'] === 'visible');
|
||||||
|
|
||||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||||
$loader->load('services.yaml');
|
$loader->load('services.yaml');
|
||||||
@@ -39,6 +39,24 @@ final class ChillAsideActivityExtension extends Extension implements PrependExte
|
|||||||
{
|
{
|
||||||
$this->prependRoute($container);
|
$this->prependRoute($container);
|
||||||
$this->prependCruds($container);
|
$this->prependCruds($container);
|
||||||
|
$this->prependTwigConfig($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prependTwigConfig(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
// Get the configuration for this bundle
|
||||||
|
$chillAsideActivityConfig = $container->getExtensionConfig($this->getAlias());
|
||||||
|
$config = $this->processConfiguration($this->getConfiguration($chillAsideActivityConfig, $container), $chillAsideActivityConfig);
|
||||||
|
|
||||||
|
// Add configuration to twig globals
|
||||||
|
$twigConfig = [
|
||||||
|
'globals' => [
|
||||||
|
'chill_aside_activity_config' => [
|
||||||
|
'show_concerned_persons_count' => $config['show_concerned_persons_count'] === 'visible',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$container->prependExtensionConfig('twig', $twigConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function prependCruds(ContainerBuilder $container)
|
protected function prependCruds(ContainerBuilder $container)
|
||||||
|
@@ -142,8 +142,9 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->booleanNode('show_concerned_persons_count')
|
->enumNode('show_concerned_persons_count')
|
||||||
->defaultTrue()
|
->values(['hidden', 'visible'])
|
||||||
|
->defaultValue('hidden')
|
||||||
->info('Show the concerned persons count field in aside activity forms and views')
|
->info('Show the concerned persons count field in aside activity forms and views')
|
||||||
->end()
|
->end()
|
||||||
->end();
|
->end();
|
||||||
|
@@ -38,8 +38,10 @@
|
|||||||
<dt class="inline">{{ 'Duration'|trans }}</dt>
|
<dt class="inline">{{ 'Duration'|trans }}</dt>
|
||||||
<dd>{{ entity.duration|date('H:i') }}</dd>
|
<dd>{{ entity.duration|date('H:i') }}</dd>
|
||||||
|
|
||||||
|
{% if chill_aside_activity_config.show_concerned_persons_count == 'visible' %}
|
||||||
<dt class="inline">{{ 'Concerned persons count'|trans }}</dt>
|
<dt class="inline">{{ 'Concerned persons count'|trans }}</dt>
|
||||||
<dd>{{ entity.concernedPersonsCount }}</dd>
|
<dd>{{ entity.concernedPersonsCount }}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<dt class="inline">{{ 'Remark'|trans }}</dt>
|
<dt class="inline">{{ 'Remark'|trans }}</dt>
|
||||||
{%- if entity.note is empty -%}
|
{%- if entity.note is empty -%}
|
||||||
|
Reference in New Issue
Block a user