cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,20 +1,10 @@
<?php
/*
* Copyright (C) 2014-2018 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\MainBundle\DependencyInjection;
@@ -23,60 +13,64 @@ use Chill\MainBundle\Controller\AddressApiController;
use Chill\MainBundle\Controller\LocationController;
use Chill\MainBundle\Controller\LocationTypeController;
use Chill\MainBundle\Controller\UserController;
use Chill\MainBundle\Doctrine\DQL\JsonbArrayLength;
use Chill\MainBundle\Doctrine\DQL\STContains;
use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Form\UserJobType;
use Chill\MainBundle\Form\UserType;
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\Widget\Factory\WidgetFactoryInterface;
use Chill\MainBundle\DependencyInjection\Configuration;
use Chill\MainBundle\Doctrine\DQL\GetJsonFieldByKey;
use Chill\MainBundle\Doctrine\DQL\Unaccent;
use Chill\MainBundle\Doctrine\DQL\JsonAggregate;
use Chill\MainBundle\Doctrine\DQL\JsonbArrayLength;
use Chill\MainBundle\Doctrine\DQL\JsonbExistsInArray;
use Chill\MainBundle\Doctrine\DQL\Similarity;
use Chill\MainBundle\Doctrine\DQL\OverlapsI;
use Chill\MainBundle\Doctrine\DQL\Replace;
use Chill\MainBundle\Doctrine\DQL\Similarity;
use Chill\MainBundle\Doctrine\DQL\STContains;
use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS;
use Chill\MainBundle\Doctrine\DQL\Unaccent;
use Chill\MainBundle\Doctrine\ORM\Hydration\FlatHierarchyEntityHydrator;
use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType;
use Chill\MainBundle\Doctrine\Type\PointType;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\LocationType;
use Chill\MainBundle\Form\LocationTypeType;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Form\LocationFormType;
use Chill\MainBundle\Form\LocationTypeType;
use Chill\MainBundle\Form\UserJobType;
use Chill\MainBundle\Form\UserType;
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 ChillMainExtension
* This class load config for chillMainExtension.
*
* @package Chill\MainBundle\DependencyInjection
*/
class ChillMainExtension extends Extension implements PrependExtensionInterface,
class ChillMainExtension extends Extension implements
PrependExtensionInterface,
Widget\HasWidgetFactoriesExtensionInterface
{
/**
* widget factory
* widget factory.
*
* @var WidgetFactoryInterface[]
*/
protected $widgetFactories = array();
protected $widgetFactories = [];
/**
* @param WidgetFactoryInterface $factory
*/
public function addWidgetFactory(WidgetFactoryInterface $factory)
{
$this->widgetFactories[] = $factory;
}
/**
* @return \Chill\MainBundle\DependencyInjection\Configuration|object|\Symfony\Component\Config\Definition\ConfigurationInterface|null
*/
public function getConfiguration(array $config, ContainerBuilder $container)
{
return new Configuration($this->widgetFactories, $container);
}
/**
* @return WidgetFactoryInterface[]
*/
@@ -86,10 +80,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
}
/**
* {@inheritDoc}
* @param array $configs
* @param ContainerBuilder $container
* @throws \Exception
* @throws Exception
*/
public function load(array $configs, ContainerBuilder $container)
{
@@ -101,38 +92,55 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
$container->setParameter('chill_main', $config);
// legacy config
$container->setParameter('chill_main.installation_name',
$config['installation_name']);
$container->setParameter(
'chill_main.installation_name',
$config['installation_name']
);
$container->setParameter('chill_main.available_languages',
$config['available_languages']);
$container->setParameter(
'chill_main.available_languages',
$config['available_languages']
);
$container->setParameter('chill_main.available_countries',
$config['available_countries']);
$container->setParameter(
'chill_main.available_countries',
$config['available_countries']
);
$container->setParameter('chill_main.routing.resources',
$config['routing']['resources']);
$container->setParameter(
'chill_main.routing.resources',
$config['routing']['resources']
);
$container->setParameter('chill_main.pagination.item_per_page',
$config['pagination']['item_per_page']);
$container->setParameter(
'chill_main.pagination.item_per_page',
$config['pagination']['item_per_page']
);
$container->setParameter('chill_main.notifications',
$config['notifications']);
$container->setParameter(
'chill_main.notifications',
$config['notifications']
);
$container->setParameter('chill_main.redis',
$config['redis']);
$container->setParameter(
'chill_main.redis',
$config['redis']
);
$container->setParameter('chill_main.phone_helper',
$config['phone_helper'] ?? []);
$container->setParameter(
'chill_main.phone_helper',
$config['phone_helper'] ?? []
);
// add the key 'widget' without the key 'enable'
$container->setParameter('chill_main.widgets',
$container->setParameter(
'chill_main.widgets',
isset($config['widgets']['homepage']) ?
array('homepage' => $config['widgets']['homepage']):
array()
);
['homepage' => $config['widgets']['homepage']] :
[]
);
$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/doctrine.yaml');
$loader->load('services/logger.yaml');
@@ -159,33 +167,20 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
$this->configureCruds($container, $config['cruds'], $config['apis'], $loader);
}
/**
* @param array $config
* @param ContainerBuilder $container
* @return \Chill\MainBundle\DependencyInjection\Configuration|null|object|\Symfony\Component\Config\Definition\ConfigurationInterface
*/
public function getConfiguration(array $config, ContainerBuilder $container)
{
return new Configuration($this->widgetFactories, $container);
}
/**
* @param ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container)
{
//add installation_name and date_format to globals
$chillMainConfig = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration($this
->getConfiguration($chillMainConfig, $container), $chillMainConfig);
$twigConfig = array(
'globals' => array(
'installation' => array(
'name' => $config['installation_name']),
'available_languages' => $config['available_languages']
),
'form_themes' => array('@ChillMain/Form/fields.html.twig')
);
->getConfiguration($chillMainConfig, $container), $chillMainConfig);
$twigConfig = [
'globals' => [
'installation' => [
'name' => $config['installation_name'], ],
'available_languages' => $config['available_languages'],
],
'form_themes' => ['@ChillMain/Form/fields.html.twig'],
];
$container->prependExtensionConfig('twig', $twigConfig);
//add DQL function to ORM (default entity_manager)
@@ -215,7 +210,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
],
],
],
);
);
//add dbal types (default entity_manager)
$container
@@ -231,45 +226,43 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
],
'types' => [
'dateinterval' => [
'class' => NativeDateIntervalType::class
'class' => NativeDateIntervalType::class,
],
'point' => [
'class' => PointType::class
]
]
]
'class' => PointType::class,
],
],
],
]
);
);
//add current route to chill main
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
'@ChillMainBundle/config/routes.yaml'
)
)
));
$container->prependExtensionConfig('chill_main', [
'routing' => [
'resources' => [
'@ChillMainBundle/config/routes.yaml',
],
],
]);
//add a channel to log app events
$container->prependExtensionConfig('monolog', array(
'channels' => array('chill')
));
$container->prependExtensionConfig('monolog', [
'channels' => ['chill'],
]);
//add crud api
$this->prependCruds($container);
}
/**
* Load parameter for configuration and set parameters for api
* Load parameter for configuration and set parameters for api.
*/
protected function configureCruds(
ContainerBuilder $container,
array $crudConfig,
array $apiConfig,
Loader\YamlFileLoader $loader
): void
{
): void {
if (count($crudConfig) === 0) {
return;
}
@@ -282,10 +275,6 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
// Note: the controller are loaded inside compiler pass
}
/**
* @param ContainerBuilder $container
*/
protected function prependCruds(ContainerBuilder $container)
{
$container->prependExtensionConfig('chill_main', [
@@ -302,11 +291,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'template' => '@ChillMain/UserJob/index.html.twig',
],
'new' => [
'role' => 'ROLE_ADMIN'
'role' => 'ROLE_ADMIN',
],
'edit' => [
'role' => 'ROLE_ADMIN'
]
'role' => 'ROLE_ADMIN',
],
],
],
[
@@ -319,17 +308,17 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'actions' => [
'index' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/User/index.html.twig'
'template' => '@ChillMain/User/index.html.twig',
],
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/User/new.html.twig'
'template' => '@ChillMain/User/new.html.twig',
],
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/User/edit.html.twig'
]
]
'template' => '@ChillMain/User/edit.html.twig',
],
],
],
[
'class' => Location::class,
@@ -343,15 +332,15 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/Location/index.html.twig',
],
'new' => [
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/Location/new.html.twig',
],
'edit' => [
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/Location/edit.html.twig',
]
]
],
],
],
[
'class' => LocationType::class,
@@ -365,15 +354,15 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/LocationType/index.html.twig',
],
'new' => [
'new' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/LocationType/new.html.twig',
],
'edit' => [
'edit' => [
'role' => 'ROLE_ADMIN',
'template' => '@ChillMain/LocationType/edit.html.twig',
]
]
],
],
],
],
'apis' => [
@@ -387,7 +376,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
Request::METHOD_HEAD => true,
],
],
'_entity' => [
@@ -395,10 +384,10 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
Request::METHOD_GET => true,
Request::METHOD_POST => true,
Request::METHOD_HEAD => true,
Request::METHOD_PATCH => true
]
Request::METHOD_PATCH => true,
],
],
]
],
],
[
'controller' => \Chill\MainBundle\Controller\AddressReferenceAPIController::class,
@@ -410,16 +399,16 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_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,
],
],
]
],
],
[
'controller' => \Chill\MainBundle\Controller\PostalCodeAPIController::class,
@@ -431,7 +420,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
Request::METHOD_HEAD => true,
],
],
'_entity' => [
@@ -439,9 +428,9 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
Request::METHOD_POST => true,
]
],
],
]
],
],
[
'class' => \Chill\MainBundle\Entity\Country::class,
@@ -452,16 +441,16 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_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\MainBundle\Entity\User::class,
@@ -473,16 +462,16 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
Request::METHOD_HEAD => true,
],
],
'_entity' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
]
],
],
]
],
],
[
'class' => \Chill\MainBundle\Entity\Scope::class,
@@ -493,16 +482,16 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
Request::METHOD_HEAD => true,
],
],
'_entity' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
]
],
],
]
],
],
[
'class' => \Chill\MainBundle\Entity\Location::class,
@@ -514,7 +503,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
Request::METHOD_HEAD => true,
],
],
'_entity' => [
@@ -522,10 +511,9 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
Request::METHOD_POST => true,
]
],
],
]
],
],
[
'class' => \Chill\MainBundle\Entity\LocationType::class,
@@ -537,19 +525,18 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
Request::METHOD_HEAD => true,
],
],
'_entity' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
]
],
],
]
]
]
],
],
],
]);
}
}