Merge remote-tracking branch 'origin/upgrade-sf3' into upgrade-sf3

This commit is contained in:
Julien Fastré 2018-04-04 12:37:53 +02:00
commit f881b3e52a
11 changed files with 299 additions and 282 deletions

View File

@ -413,7 +413,7 @@ class UserController extends Controller
->setAction($this->generateUrl('admin_user_add_group_center',
array('uid' => $user->getId())))
->setMethod('POST')
->add(self::FORM_GROUP_CENTER_COMPOSED, new ComposedGroupCenterType())
->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class)
->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
->getForm()
;

View File

@ -26,6 +26,7 @@ use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Chill\MainBundle\Export\ExportManager;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
// command to get the report with curl : curl --user "center a_social:password" "http://localhost:8000/fr/exports/generate/count_person?export[filters][person_gender_filter][enabled]=&export[filters][person_nationality_filter][enabled]=&export[filters][person_nationality_filter][form][nationalities]=&export[aggregators][person_nationality_aggregator][order]=1&export[aggregators][person_nationality_aggregator][form][group_by_level]=country&export[submit]=&export[_token]=RHpjHl389GrK-bd6iY5NsEqrD5UKOTHH40QKE9J1edU" --globoff
@ -116,7 +117,7 @@ class CSVFormatter implements FormatterInterface
*/
private function appendAggregatorForm(FormBuilderInterface $builder, $nbAggregators)
{
$builder->add('order', 'choice', array(
$builder->add('order', ChoiceType::class, array(
'choices' => array_combine(
range(1, $nbAggregators),
range(1, $nbAggregators)
@ -125,7 +126,7 @@ class CSVFormatter implements FormatterInterface
'expanded' => false
));
$builder->add('position', 'choice', array(
$builder->add('position', ChoiceType::class, array(
'choices' => array(
'row' => 'r',
'column' => 'c'

View File

@ -189,7 +189,7 @@ class SpreadSheetFormatter implements FormatterInterface
*/
private function appendAggregatorForm(FormBuilderInterface $builder, $nbAggregators)
{
$builder->add('order', 'choice', array(
$builder->add('order', ChoiceType::class, array(
'choices' => array_combine(
range(1, $nbAggregators),
range(1, $nbAggregators)

View File

@ -31,6 +31,7 @@ use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Center;
use Symfony\Component\Security\Core\Role\Role;
use Chill\MainBundle\Form\Type\DataTransformer\ScopeTransformer;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
* Trait to add an input with reachable scope for a given center and role.
@ -119,7 +120,7 @@ trait AppendScopeChoiceTypeTrait
$form = $event->getForm();
$form->add(
$builder
->create($name, 'choice', array(
->create($name, ChoiceType::class, array(
'choices' => $choices,
'auto_initialize' => false
)

View File

@ -22,6 +22,8 @@ namespace Chill\MainBundle\Form\Type;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\Center;
@ -35,12 +37,12 @@ class ComposedGroupCenterType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('permissionsgroup', 'entity', array(
$builder->add('permissionsgroup', EntityType::class, array(
'class' => 'Chill\MainBundle\Entity\PermissionsGroup',
'choice_label' => function(PermissionsGroup $group) {
return $group->getName();
}
))->add('center', 'entity', array(
))->add('center', EntityType::class, array(
'class' => 'Chill\MainBundle\Entity\Center',
'choice_label' => function(Center $center) {
return $center->getName();

View File

@ -23,11 +23,15 @@ namespace Chill\MainBundle\Form\Type;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Security\RoleProvider;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
/**
* Form to Edit/create a role scope. If the role scope does not
@ -85,7 +89,7 @@ class ComposedRoleScopeType extends AbstractType
}
$builder
->add('role', 'choice', array(
->add('role', ChoiceType::class, array(
'choices' => $values,
'placeholder' => 'Choose amongst roles',
'choice_attr' => function($role) use ($rolesWithoutScopes) {
@ -99,7 +103,7 @@ class ComposedRoleScopeType extends AbstractType
return $this->roleProvider->getRoleTitle($role);
}
))
->add('scope', 'entity', array(
->add('scope', EntityType::class, array(
'class' => 'ChillMainBundle:Scope',
'choice_label' => function(Scope $scope) use ($translatableStringHelper) {
return $translatableStringHelper->localize($scope->getName());

View File

@ -22,6 +22,8 @@ namespace Chill\MainBundle\Form\Type\Export;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Chill\MainBundle\Export\ExportManager;
/**
@ -51,7 +53,7 @@ class PickFormatterType extends AbstractType
$choices[$formatter->getName()] = $alias;
}
$builder->add('alias', 'choice', array(
$builder->add('alias', ChoiceType::class, array(
'choices' => $choices,
'choices_as_values' => true,
'multiple' => false

View File

@ -26,6 +26,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Form\FormBuilderInterface;
use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer;
use Doctrine\Common\Persistence\ObjectManager;
use Chill\MainBundle\Form\Type\Select2ChoiceType;
/**
* Extends choice to allow adding select2 library on widget
@ -64,7 +65,7 @@ class Select2CountryType extends AbstractType
public function getParent()
{
return 'select2_choice';
return Select2ChoiceType::class;
}
public function configureOptions(OptionsResolver $resolver)

View File

@ -26,6 +26,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Form\FormBuilderInterface;
use Chill\MainBundle\Form\Type\DataTransformer\MultipleObjectsToIdTransformer;
use Doctrine\Common\Persistence\ObjectManager;
use Chill\MainBundle\Form\Type\Select2ChoiceType;
/**
* Extends choice to allow adding select2 library on widget for languages (multiple)
@ -61,7 +62,7 @@ class Select2LanguageType extends AbstractType
public function getParent()
{
return 'select2_choice';
return Select2ChoiceType::class;
}
public function configureOptions(OptionsResolver $resolver)

View File

@ -8,6 +8,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
class UserPasswordType extends AbstractType
{
@ -18,8 +20,8 @@ class UserPasswordType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('password', 'repeated', array(
'type' => 'password',
->add('password', RepeatedType::class, array(
'type' => PasswordType::class,
'required' => false,
'options' => array(),
'first_options' => array(

View File

@ -5,6 +5,8 @@ namespace Chill\MainBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Chill\MainBundle\Form\UserPasswordType;
class UserType extends AbstractType
@ -25,13 +27,14 @@ class UserType extends AbstractType
} else {
$builder->add($builder
->create('enabled', 'choice', array(
->create('enabled', ChoiceType::class, array(
'choices' => array(
0 => 'Disabled, the user is not allowed to login',
1 => 'Enabled, the user is active'
'Disabled, the user is not allowed to login' => 0,
'Enabled, the user is active' => 1
),
'expanded' => false,
'multiple' => false
'multiple' => false,
'choices_as_values' => true // Can be removed when upgraded to Sf3.
))
);
}
@ -48,7 +51,7 @@ class UserType extends AbstractType
$resolver
->setDefaults(array('is_creation' => false))
->addAllowedValues(array('is_creation' => array(true, false)))
->addAllowedValues('is_creation', array(true, false))
;
}