mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
change namespaces, removing AMLI
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?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\BudgetBundle\DependencyInjection;
|
||||
|
||||
use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration.
|
||||
*
|
||||
* @see http://symfony.com/doc/current/cookbook/bundles/extension.html
|
||||
*/
|
||||
class ChillBudgetExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
||||
$loader->load('services/config.yaml');
|
||||
$loader->load('services/form.yaml');
|
||||
$loader->load('services/security.yaml');
|
||||
$loader->load('services/controller.yaml');
|
||||
$loader->load('services/templating.yaml');
|
||||
$loader->load('services/menu.yaml');
|
||||
$loader->load('services/calculator.yaml');
|
||||
|
||||
$this->storeConfig('resources', $config, $container);
|
||||
$this->storeConfig('charges', $config, $container);
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->prependAuthorization($container);
|
||||
$this->prependRoutes($container);
|
||||
}
|
||||
|
||||
/** (non-PHPdoc).
|
||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||
*/
|
||||
public function prependRoutes(ContainerBuilder $container)
|
||||
{
|
||||
//add routes for custom bundle
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'routing' => [
|
||||
'resources' => [
|
||||
'@ChillBudgetBundle/config/routing.yaml',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
protected function prependAuthorization(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('security', [
|
||||
'role_hierarchy' => [
|
||||
BudgetElementVoter::UPDATE => [BudgetElementVoter::SHOW],
|
||||
BudgetElementVoter::CREATE => [BudgetElementVoter::SHOW],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
protected function storeConfig($position, array $config, ContainerBuilder $container)
|
||||
{
|
||||
$container
|
||||
->setParameter(sprintf('chill_budget.%s', $position), $config[$position]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user