mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
168 lines
7.1 KiB
PHP
168 lines
7.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace Chill\ActivityBundle\DependencyInjection;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\Config\FileLocator;
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|
use Symfony\Component\DependencyInjection\Loader;
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
|
|
/**
|
|
* This is the class that loads and manages your bundle configuration
|
|
*
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
|
*/
|
|
class ChillActivityExtension extends Extension implements PrependExtensionInterface
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function load(array $configs, ContainerBuilder $container)
|
|
{
|
|
$configuration = new Configuration();
|
|
$config = $this->processConfiguration($configuration, $configs);
|
|
|
|
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
|
|
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
|
$loader->load('services.yaml');
|
|
$loader->load('services/export.yaml');
|
|
$loader->load('services/repositories.yaml');
|
|
$loader->load('services/fixtures.yaml');
|
|
$loader->load('services/controller.yaml');
|
|
$loader->load('services/form.yaml');
|
|
$loader->load('services/templating.yaml');
|
|
$loader->load('services/accompanyingPeriodConsistency.yaml');
|
|
}
|
|
|
|
public function prepend(ContainerBuilder $container)
|
|
{
|
|
$this->prependRoutes($container);
|
|
$this->prependAuthorization($container);
|
|
$this->prependCruds($container);
|
|
}
|
|
|
|
/* (non-PHPdoc)
|
|
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
|
*/
|
|
public function prependRoutes(ContainerBuilder $container)
|
|
{
|
|
//add routes for custom bundle
|
|
$container->prependExtensionConfig('chill_main', array(
|
|
'routing' => array(
|
|
'resources' => array(
|
|
'@ChillActivityBundle/config/routes.yaml'
|
|
)
|
|
)
|
|
));
|
|
}
|
|
|
|
public function prependAuthorization(ContainerBuilder $container)
|
|
{
|
|
$container->prependExtensionConfig('security', array(
|
|
'role_hierarchy' => array(
|
|
ActivityVoter::UPDATE => array(ActivityVoter::SEE_DETAILS),
|
|
ActivityVoter::CREATE => array(ActivityVoter::SEE_DETAILS),
|
|
ActivityVoter::DELETE => array(ActivityVoter::SEE_DETAILS),
|
|
ActivityVoter::SEE_DETAILS => array(ActivityVoter::SEE),
|
|
ActivityVoter::FULL => [ActivityVoter::CREATE, ActivityVoter::DELETE,
|
|
ActivityVoter::UPDATE],
|
|
)
|
|
));
|
|
}
|
|
|
|
protected function prependCruds(ContainerBuilder $container)
|
|
{
|
|
$container->prependExtensionConfig('chill_main', [
|
|
'cruds' => [
|
|
[
|
|
'class' => \Chill\ActivityBundle\Entity\ActivityType::class,
|
|
'name' => 'activity_type',
|
|
'base_path' => '/admin/activity/type',
|
|
'form_class' => \Chill\ActivityBundle\Form\ActivityTypeType::class,
|
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeController::class,
|
|
'actions' => [
|
|
'index' => [
|
|
'template' => '@ChillActivity/ActivityType/index.html.twig',
|
|
'role' => 'ROLE_ADMIN'
|
|
],
|
|
'new' => [
|
|
'role' => 'ROLE_ADMIN',
|
|
'template' => '@ChillActivity/ActivityType/new.html.twig',
|
|
],
|
|
'edit' => [
|
|
'role' => 'ROLE_ADMIN',
|
|
'template' => '@ChillActivity/ActivityType/edit.html.twig',
|
|
]
|
|
]
|
|
],
|
|
[
|
|
'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class,
|
|
'name' => 'activity_type_category',
|
|
'base_path' => '/admin/activity/type_category',
|
|
'form_class' => \Chill\ActivityBundle\Form\ActivityTypeCategoryType::class,
|
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeCategoryController::class,
|
|
'actions' => [
|
|
'index' => [
|
|
'template' => '@ChillActivity/ActivityTypeCategory/index.html.twig',
|
|
'role' => 'ROLE_ADMIN'
|
|
],
|
|
'new' => [
|
|
'role' => 'ROLE_ADMIN',
|
|
'template' => '@ChillActivity/ActivityTypeCategory/new.html.twig',
|
|
],
|
|
'edit' => [
|
|
'role' => 'ROLE_ADMIN',
|
|
'template' => '@ChillActivity/ActivityTypeCategory/edit.html.twig',
|
|
]
|
|
]
|
|
],
|
|
[
|
|
'class' => \Chill\ActivityBundle\Entity\ActivityPresence::class,
|
|
'name' => 'activity_presence',
|
|
'base_path' => '/admin/activity/presence',
|
|
'form_class' => \Chill\ActivityBundle\Form\ActivityPresenceType::class,
|
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityPresenceController::class,
|
|
'actions' => [
|
|
'index' => [
|
|
'template' => '@ChillActivity/ActivityPresence/index.html.twig',
|
|
'role' => 'ROLE_ADMIN'
|
|
],
|
|
'new' => [
|
|
'role' => 'ROLE_ADMIN',
|
|
'template' => '@ChillActivity/ActivityPresence/new.html.twig',
|
|
],
|
|
'edit' => [
|
|
'role' => 'ROLE_ADMIN',
|
|
'template' => '@ChillActivity/ActivityPresence/edit.html.twig',
|
|
]
|
|
]
|
|
],
|
|
]
|
|
]);
|
|
}
|
|
}
|