mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-13 00:13:44 +00:00
Add configurable homepage tabs with validation for default tab inclusion
This commit is contained in:
@@ -84,6 +84,7 @@ use Chill\MainBundle\Security\Authorization\ChillExportVoter;
|
||||
use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter;
|
||||
use Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType;
|
||||
use Ramsey\Uuid\Doctrine\UuidType;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
@@ -210,6 +211,15 @@ class ChillMainExtension extends Extension implements
|
||||
$config['top_banner'] ?? []
|
||||
);
|
||||
|
||||
if (!in_array($config['homepage']['default_tab'], $config['homepage']['display_tabs'], true)) {
|
||||
throw new InvalidConfigurationException('The chill_main.homepage.default_tab must be included in chill_main.homepage.display_tabs');
|
||||
}
|
||||
|
||||
$container->setParameter(
|
||||
'chill_main.homepage',
|
||||
$config['homepage']
|
||||
);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('services/doctrine.yaml');
|
||||
@@ -241,7 +251,7 @@ class ChillMainExtension extends Extension implements
|
||||
// $this->configureSms($config['short_messages'], $container, $loader);
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
public function prepend(ContainerBuilder $container): void
|
||||
{
|
||||
$this->prependNotifierTexterWithLegacyData($container);
|
||||
|
||||
@@ -256,6 +266,7 @@ class ChillMainExtension extends Extension implements
|
||||
'available_languages' => $config['available_languages'],
|
||||
'add_address' => $config['add_address'],
|
||||
'chill_main_config' => $config,
|
||||
'homepage_widget_config' => $config['homepage'],
|
||||
],
|
||||
'form_themes' => ['@ChillMain/Form/fields.html.twig'],
|
||||
];
|
||||
|
||||
@@ -325,6 +325,17 @@ class Configuration implements ConfigurationInterface
|
||||
->end()
|
||||
->end();
|
||||
|
||||
/* @phpstan-ignore-next-line */
|
||||
$rootNode->children()
|
||||
->arrayNode('homepage')->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default_tab')->defaultValue('MyCustoms')->end()
|
||||
->arrayNode('display_tabs')
|
||||
->info('List of tabs to display on the homepage.')
|
||||
->defaultValue(['MyCustoms', 'MyNotifications', 'MyAccompanyingCourses', 'MyEvaluations', 'MyTasks', 'MyWorkflows'])
|
||||
->scalarPrototype()->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user