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,29 +1,33 @@
<?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.
*/
namespace Chill\CustomFieldsBundle\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\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
* 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 ChillCustomFieldsExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$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/fixtures.yaml');
$loader->load('services/controller.yaml');
@@ -34,15 +38,19 @@ class ChillCustomFieldsExtension extends Extension implements PrependExtensionIn
// && $config['customizables_entities'] !== FALSE)
// ? $config['customizables_entities'] : array();
$container->setParameter('chill_custom_fields.customizables_entities',
$config['customizables_entities']);
$container->setParameter('chill_custom_fields.show_empty_values',
$config['show_empty_values_in_views']);
$container->setParameter(
'chill_custom_fields.customizables_entities',
$config['customizables_entities']
);
$container->setParameter(
'chill_custom_fields.show_empty_values',
$config['show_empty_values_in_views']
);
}
/* (non-PHPdoc)
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
/* (non-PHPdoc)
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
*/
public function prepend(ContainerBuilder $container)
{
// add form layout to twig resources
@@ -54,12 +62,12 @@ class ChillCustomFieldsExtension extends Extension implements PrependExtensionIn
$container->prependExtensionConfig('twig', $twigConfig);
//add routes for custom bundle
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
'@ChillCustomFieldsBundle/config/routes.yaml'
)
)
));
$container->prependExtensionConfig('chill_main', [
'routing' => [
'resources' => [
'@ChillCustomFieldsBundle/config/routes.yaml',
],
],
]);
}
}

View File

@@ -1,70 +1,73 @@
<?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.
*/
namespace Chill\CustomFieldsBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from
* your app/config files
* This is the class that validates and merges configuration from
* your app/config files.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('chill_custom_fields');
$rootNode = $treeBuilder->getRootNode('chill_custom_fields');
$classInfo = "The class which may receive custom fields";
$nameInfo = "The name which will appears in the user interface. May be translatable";
$optionsInfo = "Options available for custom fields groups referencing this class";
$optionsFormType = "The name of the form to append";
$optionsFormOptionsInfos = "the arguments to pass the form";
$customizableEntitiesInfo = "A list of customizable entities";
$classInfo = 'The class which may receive custom fields';
$nameInfo = 'The name which will appears in the user interface. May be translatable';
$optionsInfo = 'Options available for custom fields groups referencing this class';
$optionsFormType = 'The name of the form to append';
$optionsFormOptionsInfos = 'the arguments to pass the form';
$customizableEntitiesInfo = 'A list of customizable entities';
$rootNode
->children()
->arrayNode('customizables_entities')
->info($customizableEntitiesInfo)
->defaultValue(array())
->prototype('array')
->children()
->scalarNode('class')->isRequired()->info($classInfo)
->end()
->scalarNode('name') ->isRequired()->info($nameInfo)
->end()
->arrayNode('options')
->info($optionsInfo)
->defaultValue(array())
->useAttributeAsKey('key')
->prototype('array')
->children()
->scalarNode('form_type')
->isRequired()
->info($optionsFormType)
->end()
->variableNode('form_options')
->info($optionsFormOptionsInfos)
->defaultValue(array())
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('customizables_entities')
->info($customizableEntitiesInfo)
->defaultValue([])
->prototype('array')
->children()
->scalarNode('class')->isRequired()->info($classInfo)
->end()
->scalarNode('name')->isRequired()->info($nameInfo)
->end()
->arrayNode('options')
->info($optionsInfo)
->defaultValue([])
->useAttributeAsKey('key')
->prototype('array')
->children()
->scalarNode('form_type')
->isRequired()
->info($optionsFormType)
->end()
->variableNode('form_options')
->info($optionsFormOptionsInfos)
->defaultValue([])
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->booleanNode('show_empty_values_in_views')
->info('Show the empty value for custom fields in the views, timeline, ...')
->defaultValue(true)
->info('Show the empty value for custom fields in the views, timeline, ...')
->defaultValue(true)
->end()
->end()
;
->end();
return $treeBuilder;
}

View File

@@ -1,43 +1,43 @@
<?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.
*/
namespace Chill\CustomFieldsBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use LogicException;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class CustomFieldCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('chill.custom_field.provider')) {
throw new \LogicException('service chill.custom_field.provider '
throw new LogicException('service chill.custom_field.provider '
. 'is not defined.');
}
$definition = $container->getDefinition(
'chill.custom_field.provider'
);
$taggedServices = $container->findTaggedServiceIds(
'chill.custom_field'
);
);
foreach ($taggedServices as $id => $tagAttributes) {
foreach ($tagAttributes as $attributes) {
$definition->addMethodCall(
'addCustomField',
array(new Reference($id), $attributes["type"])
[new Reference($id), $attributes['type']]
);
}
}
}
}