mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,50 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2014-2016 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* 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/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\DependencyInjection;
|
||||
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
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\MainBundle\DependencyInjection\MissingBundleException;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
|
||||
use Chill\PersonBundle\Doctrine\DQL\AddressPart;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Exception;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* Class ChillPersonExtension
|
||||
* Loads and manages your bundle configuration
|
||||
* Loads and manages your bundle configuration.
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||
* @package Chill\PersonBundle\DependencyInjection
|
||||
*/
|
||||
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @param array $configs
|
||||
* @param ContainerBuilder $container
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
@@ -52,19 +39,23 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
// set configuration for validation
|
||||
$container->setParameter('chill_person.validation.birtdate_not_before',
|
||||
$config['validation']['birthdate_not_after']);
|
||||
$container->setParameter(
|
||||
'chill_person.validation.birtdate_not_before',
|
||||
$config['validation']['birthdate_not_after']
|
||||
);
|
||||
|
||||
$this->handlePersonFieldsParameters($container, $config['person_fields']);
|
||||
$this->handleAccompanyingPeriodsFieldsParameters($container, $config['accompanying_periods_fields']);
|
||||
|
||||
$container->setParameter('chill_person.allow_multiple_simultaneous_accompanying_periods',
|
||||
$config['allow_multiple_simultaneous_accompanying_periods']);
|
||||
$container->setParameter(
|
||||
'chill_person.allow_multiple_simultaneous_accompanying_periods',
|
||||
$config['allow_multiple_simultaneous_accompanying_periods']
|
||||
);
|
||||
|
||||
// register all configuration in a unique parameter
|
||||
$container->setParameter('chill_person', $config);
|
||||
|
||||
$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/widgets.yaml');
|
||||
$loader->load('services/exports.yaml');
|
||||
@@ -92,70 +83,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @param $config
|
||||
*/
|
||||
private function handlePersonFieldsParameters(ContainerBuilder $container, $config)
|
||||
{
|
||||
if (array_key_exists('enabled', $config)) {
|
||||
unset($config['enabled']);
|
||||
}
|
||||
|
||||
$container->setParameter('chill_person.person_fields', $config);
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
switch($key) {
|
||||
case 'accompanying_period':
|
||||
$container->setParameter('chill_person.accompanying_period', $value);
|
||||
break;
|
||||
default:
|
||||
$container->setParameter('chill_person.person_fields.'.$key, $value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @param $config
|
||||
*/
|
||||
private function handleAccompanyingPeriodsFieldsParameters(ContainerBuilder $container, $config)
|
||||
{
|
||||
$container->setParameter('chill_person.accompanying_period_fields', $config);
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
switch($key) {
|
||||
case 'enabled':
|
||||
break;
|
||||
default:
|
||||
$container->setParameter('chill_person.accompanying_period_fields.'.$key, $value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws MissingBundleException
|
||||
*/
|
||||
private function declarePersonAsCustomizable (ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
if (!isset($bundles['ChillCustomFieldsBundle'])) {
|
||||
throw new MissingBundleException('ChillCustomFieldsBundle');
|
||||
}
|
||||
|
||||
$container->prependExtensionConfig('chill_custom_fields',
|
||||
array('customizables_entities' =>
|
||||
array(
|
||||
array('class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws MissingBundleException
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
@@ -169,152 +96,31 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
//add person_fields parameter as global
|
||||
$chillPersonConfig = $container->getExtensionConfig($this->getAlias());
|
||||
$config = $this->processConfiguration(new Configuration(), $chillPersonConfig);
|
||||
$twigConfig = array(
|
||||
'globals' => array(
|
||||
'chill_person' => array(
|
||||
'fields' => $config['person_fields']
|
||||
),
|
||||
$twigConfig = [
|
||||
'globals' => [
|
||||
'chill_person' => [
|
||||
'fields' => $config['person_fields'],
|
||||
],
|
||||
'chill_accompanying_periods' => [
|
||||
'fields' => $config['accompanying_periods_fields']
|
||||
]
|
||||
),
|
||||
'form_themes' => array('ChillPersonBundle:Export:ListPersonFormFields.html.twig')
|
||||
);
|
||||
'fields' => $config['accompanying_periods_fields'],
|
||||
],
|
||||
],
|
||||
'form_themes' => ['ChillPersonBundle:Export:ListPersonFormFields.html.twig'],
|
||||
];
|
||||
$container->prependExtensionConfig('twig', $twigConfig);
|
||||
|
||||
$this-> declarePersonAsCustomizable($container);
|
||||
$this->declarePersonAsCustomizable($container);
|
||||
|
||||
//declare routes for person bundle
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillPersonBundle/config/routes.yaml'
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
protected function prependWorkflows(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('framework', [
|
||||
'workflows' => [
|
||||
'accompanying_period_lifecycle' => [
|
||||
'type' => 'state_machine',
|
||||
'audit_trail' => [
|
||||
'enabled' => true
|
||||
],
|
||||
'marking_store' => [
|
||||
'type' => 'method',
|
||||
'property' => 'step',
|
||||
],
|
||||
'supports' => [
|
||||
'Chill\PersonBundle\Entity\AccompanyingPeriod'
|
||||
],
|
||||
'initial_marking' => 'DRAFT',
|
||||
'places' => [
|
||||
'DRAFT',
|
||||
'CONFIRMED',
|
||||
'CLOSED',
|
||||
],
|
||||
'transitions' => [
|
||||
'confirm' => [
|
||||
'from' => 'DRAFT',
|
||||
'to' => 'CONFIRMED'
|
||||
],
|
||||
'close' => [
|
||||
'from' => 'CONFIRMED',
|
||||
'to' => 'CLOSED'
|
||||
],
|
||||
],
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'routing' => [
|
||||
'resources' => [
|
||||
'@ChillPersonBundle/config/routes.yaml',
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a widget "add a person" on the homepage, automatically
|
||||
*
|
||||
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
|
||||
*/
|
||||
protected function prependHomepageWidget(containerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'widgets' => array(
|
||||
'homepage' => array(
|
||||
array(
|
||||
'widget_alias' => 'add_person',
|
||||
'order' => 2
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add role hierarchy.
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function prependRoleHierarchy(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('security', [
|
||||
'role_hierarchy' => [
|
||||
PersonVoter::UPDATE => [PersonVoter::SEE],
|
||||
PersonVoter::CREATE => [PersonVoter::SEE],
|
||||
PersonVoter::LISTS => [ChillExportVoter::EXPORT],
|
||||
PersonVoter::STATS => [ChillExportVoter::EXPORT],
|
||||
// accompanying period
|
||||
AccompanyingPeriodVoter::SEE_DETAILS => [AccompanyingPeriodVoter::SEE],
|
||||
AccompanyingPeriodVoter::CREATE => [AccompanyingPeriodVoter::SEE_DETAILS],
|
||||
AccompanyingPeriodVoter::DELETE => [AccompanyingPeriodVoter::SEE_DETAILS],
|
||||
AccompanyingPeriodVoter::EDIT => [AccompanyingPeriodVoter::SEE_DETAILS],
|
||||
// give all ACL for FULL
|
||||
AccompanyingPeriodVoter::FULL => [
|
||||
AccompanyingPeriodVoter::SEE_DETAILS,
|
||||
AccompanyingPeriodVoter::CREATE,
|
||||
AccompanyingPeriodVoter::EDIT,
|
||||
AccompanyingPeriodVoter::DELETE
|
||||
]
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add DQL function linked with person
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function prependDoctrineDQL(ContainerBuilder $container)
|
||||
{
|
||||
//add DQL function to ORM (default entity_manager)
|
||||
|
||||
$container->prependExtensionConfig('doctrine', array(
|
||||
'orm' => array(
|
||||
'dql' => array(
|
||||
'string_functions' => array(
|
||||
'GET_PERSON_ADDRESS_ADDRESS_ID' => AddressPart\AddressPartAddressId::class,
|
||||
'GET_PERSON_ADDRESS_STREET_ADDRESS_1' => AddressPart\AddressPartStreetAddress1::class,
|
||||
'GET_PERSON_ADDRESS_STREET_ADDRESS_2' => AddressPart\AddressPartStreetAddress2::class,
|
||||
'GET_PERSON_ADDRESS_VALID_FROM' => AddressPart\AddressPartValidFrom::class,
|
||||
'GET_PERSON_ADDRESS_POSTCODE_LABEL' => AddressPart\AddressPartPostCodeLabel::class,
|
||||
'GET_PERSON_ADDRESS_POSTCODE_CODE' => AddressPart\AddressPartPostCodeCode::class,
|
||||
'GET_PERSON_ADDRESS_POSTCODE_ID' => AddressPart\AddressPartPostCodeId::class,
|
||||
'GET_PERSON_ADDRESS_COUNTRY_NAME' => AddressPart\AddressPartCountryName::class,
|
||||
'GET_PERSON_ADDRESS_COUNTRY_CODE' => AddressPart\AddressPartCountryCode::class,
|
||||
'GET_PERSON_ADDRESS_COUNTRY_ID' => AddressPart\AddressPartCountryId::class,
|
||||
),
|
||||
'numeric_functions' => [
|
||||
'GET_PERSON_ADDRESS_ISNOADDRESS' => AddressPart\AddressPartIsNoAddress::class,
|
||||
]
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function prependCruds(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
@@ -328,17 +134,17 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'actions' => [
|
||||
'index' => [
|
||||
'template' => '@ChillPerson/ClosingMotive/index.html.twig',
|
||||
'role' => 'ROLE_ADMIN'
|
||||
'role' => 'ROLE_ADMIN',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/ClosingMotive/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/ClosingMotive/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\MaritalStatus::class,
|
||||
@@ -351,15 +157,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/MaritalStatus/index.html.twig',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/MaritalStatus/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/MaritalStatus/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
|
||||
@@ -372,15 +178,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/SocialIssue/index.html.twig',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialAction::class,
|
||||
@@ -393,15 +199,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/SocialAction/index.html.twig',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\Goal::class,
|
||||
@@ -414,15 +220,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/Goal/index.html.twig',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\Result::class,
|
||||
@@ -435,15 +241,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/Result/index.html.twig',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\Evaluation::class,
|
||||
@@ -456,15 +262,15 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/Evaluation/index.html.twig',
|
||||
],
|
||||
'new' => [
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/SocialWork/edit.html.twig',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'apis' => [
|
||||
@@ -484,7 +290,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_PUT => true,
|
||||
Request::METHOD_PATCH => true,
|
||||
]
|
||||
],
|
||||
],
|
||||
'participation' => [
|
||||
'methods' => [
|
||||
@@ -495,8 +301,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
Request::METHOD_DELETE => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
],
|
||||
],
|
||||
'resource' => [
|
||||
'methods' => [
|
||||
@@ -507,8 +313,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
Request::METHOD_DELETE => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
],
|
||||
],
|
||||
'comment' => [
|
||||
'methods' => [
|
||||
@@ -519,8 +325,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
Request::METHOD_DELETE => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
],
|
||||
],
|
||||
'requestor' => [
|
||||
'methods' => [
|
||||
@@ -531,8 +337,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
Request::METHOD_DELETE => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
],
|
||||
],
|
||||
'scope' => [
|
||||
'methods' => [
|
||||
@@ -543,8 +349,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
Request::METHOD_DELETE => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
],
|
||||
],
|
||||
'socialissue' => [
|
||||
'methods' => [
|
||||
@@ -556,8 +362,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'controller_action' => 'socialIssueApi',
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
Request::METHOD_DELETE => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
],
|
||||
],
|
||||
'work' => [
|
||||
'methods' => [
|
||||
@@ -570,7 +376,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE => 'ALWAYS_FAILS',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'confirm' => [
|
||||
@@ -581,7 +387,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
]
|
||||
],
|
||||
],
|
||||
'findAccompanyingPeriodsByPerson' => [
|
||||
'path' => '/by-person/{person_id}.{_format}',
|
||||
@@ -589,9 +395,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Origin::class,
|
||||
@@ -603,16 +409,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
]
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
|
||||
@@ -624,16 +430,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
]
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\Person::class,
|
||||
@@ -646,8 +452,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
Request::METHOD_POST=> true,
|
||||
Request::METHOD_PATCH => true
|
||||
Request::METHOD_POST => true,
|
||||
Request::METHOD_PATCH => true,
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_GET => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE,
|
||||
@@ -663,9 +469,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_GET => false,
|
||||
Request::METHOD_HEAD => false,
|
||||
],
|
||||
'controller_action' => 'personAddressApi'
|
||||
'controller_action' => 'personAddressApi',
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\Household\Household::class,
|
||||
@@ -684,7 +490,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
]
|
||||
],
|
||||
],
|
||||
'address' => [
|
||||
'methods' => [
|
||||
@@ -693,16 +499,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_GET => false,
|
||||
Request::METHOD_HEAD => false,
|
||||
],
|
||||
'controller_action' => 'householdAddressApi'
|
||||
'controller_action' => 'householdAddressApi',
|
||||
],
|
||||
'suggestHouseholdByAccompanyingPeriodParticipation' => [
|
||||
'path' => '/suggest/by-person/{person_id}/through-accompanying-period-participation.{_format}',
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true,
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialAction::class,
|
||||
@@ -720,7 +526,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
@@ -730,7 +536,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'listBySocialIssue' => [
|
||||
'single-collection' => 'collection',
|
||||
@@ -742,10 +548,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork::class,
|
||||
@@ -767,9 +572,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
Request::METHOD_PATCH => 'ROLE_USER',
|
||||
Request::METHOD_PUT => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\Result::class,
|
||||
@@ -786,7 +591,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
@@ -796,7 +601,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'by-social-action' => [
|
||||
'single-collection' => 'collection',
|
||||
@@ -809,7 +614,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'by-goal' => [
|
||||
'single-collection' => 'collection',
|
||||
@@ -822,9 +627,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\SocialWork\Goal::class,
|
||||
@@ -841,7 +646,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
@@ -851,7 +656,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'by-social-action' => [
|
||||
'single-collection' => 'collection',
|
||||
@@ -864,9 +669,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\Relationships\Relationship::class,
|
||||
@@ -885,7 +690,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_POST => 'ROLE_USER',
|
||||
Request::METHOD_PATCH => 'ROLE_USER',
|
||||
Request::METHOD_DELETE => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
'relationship-by-person' => [
|
||||
'path' => '/by-person/{person_id}.json',
|
||||
@@ -897,9 +702,9 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'roles' => [
|
||||
Request::METHOD_GET => 'ROLE_USER',
|
||||
Request::METHOD_HEAD => 'ROLE_USER',
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\Relationships\Relation::class,
|
||||
@@ -910,18 +715,197 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
'_index' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
]
|
||||
Request::METHOD_HEAD => true,
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add DQL function linked with person.
|
||||
*/
|
||||
protected function prependDoctrineDQL(ContainerBuilder $container)
|
||||
{
|
||||
//add DQL function to ORM (default entity_manager)
|
||||
|
||||
$container->prependExtensionConfig('doctrine', [
|
||||
'orm' => [
|
||||
'dql' => [
|
||||
'string_functions' => [
|
||||
'GET_PERSON_ADDRESS_ADDRESS_ID' => AddressPart\AddressPartAddressId::class,
|
||||
'GET_PERSON_ADDRESS_STREET_ADDRESS_1' => AddressPart\AddressPartStreetAddress1::class,
|
||||
'GET_PERSON_ADDRESS_STREET_ADDRESS_2' => AddressPart\AddressPartStreetAddress2::class,
|
||||
'GET_PERSON_ADDRESS_VALID_FROM' => AddressPart\AddressPartValidFrom::class,
|
||||
'GET_PERSON_ADDRESS_POSTCODE_LABEL' => AddressPart\AddressPartPostCodeLabel::class,
|
||||
'GET_PERSON_ADDRESS_POSTCODE_CODE' => AddressPart\AddressPartPostCodeCode::class,
|
||||
'GET_PERSON_ADDRESS_POSTCODE_ID' => AddressPart\AddressPartPostCodeId::class,
|
||||
'GET_PERSON_ADDRESS_COUNTRY_NAME' => AddressPart\AddressPartCountryName::class,
|
||||
'GET_PERSON_ADDRESS_COUNTRY_CODE' => AddressPart\AddressPartCountryCode::class,
|
||||
'GET_PERSON_ADDRESS_COUNTRY_ID' => AddressPart\AddressPartCountryId::class,
|
||||
],
|
||||
'numeric_functions' => [
|
||||
'GET_PERSON_ADDRESS_ISNOADDRESS' => AddressPart\AddressPartIsNoAddress::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a widget "add a person" on the homepage, automatically.
|
||||
*
|
||||
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
|
||||
*/
|
||||
protected function prependHomepageWidget(containerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'widgets' => [
|
||||
'homepage' => [
|
||||
[
|
||||
'widget_alias' => 'add_person',
|
||||
'order' => 2,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add role hierarchy.
|
||||
*/
|
||||
protected function prependRoleHierarchy(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('security', [
|
||||
'role_hierarchy' => [
|
||||
PersonVoter::UPDATE => [PersonVoter::SEE],
|
||||
PersonVoter::CREATE => [PersonVoter::SEE],
|
||||
PersonVoter::LISTS => [ChillExportVoter::EXPORT],
|
||||
PersonVoter::STATS => [ChillExportVoter::EXPORT],
|
||||
// accompanying period
|
||||
AccompanyingPeriodVoter::SEE_DETAILS => [AccompanyingPeriodVoter::SEE],
|
||||
AccompanyingPeriodVoter::CREATE => [AccompanyingPeriodVoter::SEE_DETAILS],
|
||||
AccompanyingPeriodVoter::DELETE => [AccompanyingPeriodVoter::SEE_DETAILS],
|
||||
AccompanyingPeriodVoter::EDIT => [AccompanyingPeriodVoter::SEE_DETAILS],
|
||||
// give all ACL for FULL
|
||||
AccompanyingPeriodVoter::FULL => [
|
||||
AccompanyingPeriodVoter::SEE_DETAILS,
|
||||
AccompanyingPeriodVoter::CREATE,
|
||||
AccompanyingPeriodVoter::EDIT,
|
||||
AccompanyingPeriodVoter::DELETE,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
protected function prependWorkflows(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('framework', [
|
||||
'workflows' => [
|
||||
'accompanying_period_lifecycle' => [
|
||||
'type' => 'state_machine',
|
||||
'audit_trail' => [
|
||||
'enabled' => true,
|
||||
],
|
||||
'marking_store' => [
|
||||
'type' => 'method',
|
||||
'property' => 'step',
|
||||
],
|
||||
'supports' => [
|
||||
'Chill\PersonBundle\Entity\AccompanyingPeriod',
|
||||
],
|
||||
'initial_marking' => 'DRAFT',
|
||||
'places' => [
|
||||
'DRAFT',
|
||||
'CONFIRMED',
|
||||
'CLOSED',
|
||||
],
|
||||
'transitions' => [
|
||||
'confirm' => [
|
||||
'from' => 'DRAFT',
|
||||
'to' => 'CONFIRMED',
|
||||
],
|
||||
'close' => [
|
||||
'from' => 'CONFIRMED',
|
||||
'to' => 'CLOSED',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MissingBundleException
|
||||
*/
|
||||
private function declarePersonAsCustomizable(ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
|
||||
if (!isset($bundles['ChillCustomFieldsBundle'])) {
|
||||
throw new MissingBundleException('ChillCustomFieldsBundle');
|
||||
}
|
||||
|
||||
$container->prependExtensionConfig(
|
||||
'chill_custom_fields',
|
||||
['customizables_entities' => [
|
||||
['class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity'],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
*/
|
||||
private function handleAccompanyingPeriodsFieldsParameters(ContainerBuilder $container, $config)
|
||||
{
|
||||
$container->setParameter('chill_person.accompanying_period_fields', $config);
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'enabled':
|
||||
break;
|
||||
|
||||
default:
|
||||
$container->setParameter('chill_person.accompanying_period_fields.' . $key, $value);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
*/
|
||||
private function handlePersonFieldsParameters(ContainerBuilder $container, $config)
|
||||
{
|
||||
if (array_key_exists('enabled', $config)) {
|
||||
unset($config['enabled']);
|
||||
}
|
||||
|
||||
$container->setParameter('chill_person.person_fields', $config);
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'accompanying_period':
|
||||
$container->setParameter('chill_person.accompanying_period', $value);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$container->setParameter('chill_person.person_fields.' . $key, $value);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user