mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
Merge branch 'master' into upgrade-sf5
This commit is contained in:
@@ -46,7 +46,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedPostalCodes,
|
||||
static fn (PostalCode $pc = null) => \call_user_func($value, $pc)
|
||||
static fn (?PostalCode $pc = null) => \call_user_func($value, $pc)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,9 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
|
||||
{
|
||||
public function __construct(private readonly Security $security) {}
|
||||
public function __construct(private readonly Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
public function mapDataToForms($viewData, iterable $forms)
|
||||
{
|
||||
|
@@ -16,7 +16,9 @@ use Symfony\Component\Form\DataMapperInterface;
|
||||
|
||||
class ScopePickerDataMapper implements DataMapperInterface
|
||||
{
|
||||
public function __construct(private readonly ?Scope $scope = null) {}
|
||||
public function __construct(private readonly ?Scope $scope = null)
|
||||
{
|
||||
}
|
||||
|
||||
public function mapDataToForms($data, iterable $forms)
|
||||
{
|
||||
|
@@ -35,7 +35,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
|
||||
public function __construct(
|
||||
private readonly ObjectRepository $repository,
|
||||
private readonly bool $multiple = false,
|
||||
callable $getId = null
|
||||
?callable $getId = null
|
||||
) {
|
||||
$this->getId = $getId ?? static fn (object $o) => $o->getId();
|
||||
}
|
||||
|
@@ -17,7 +17,9 @@ class CustomizeFormEvent extends \Symfony\Contracts\EventDispatcher\Event
|
||||
{
|
||||
final public const NAME = 'chill_main.customize_form';
|
||||
|
||||
public function __construct(protected string $type, protected FormBuilderInterface $builder) {}
|
||||
public function __construct(protected string $type, protected FormBuilderInterface $builder)
|
||||
{
|
||||
}
|
||||
|
||||
public function getBuilder(): FormBuilderInterface
|
||||
{
|
||||
|
@@ -24,7 +24,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
final class LocationFormType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -27,7 +28,13 @@ class ComposedGroupCenterType extends AbstractType
|
||||
'choice_label' => static fn (PermissionsGroup $group) => $group->getName(),
|
||||
])->add('center', EntityType::class, [
|
||||
'class' => Center::class,
|
||||
'choice_label' => static fn (Center $center) => $center->getName(),
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('c');
|
||||
$qb->where($qb->expr()->eq('c.isActive', 'TRUE'))
|
||||
->orderBy('c.name', 'ASC');
|
||||
|
||||
return $qb;
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
*/
|
||||
class ComposedRoleScopeType extends AbstractType
|
||||
{
|
||||
private readonly \Chill\MainBundle\Security\RoleProvider $roleProvider;
|
||||
private readonly RoleProvider $roleProvider;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
|
@@ -17,7 +17,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
final readonly class AddressToIdDataTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private AddressRepository $addressRepository) {}
|
||||
public function __construct(private AddressRepository $addressRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public function reverseTransform($value)
|
||||
{
|
||||
|
@@ -20,7 +20,9 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
|
||||
class CenterTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false) {}
|
||||
public function __construct(private readonly CenterRepository $centerRepository, private readonly bool $multiple = false)
|
||||
{
|
||||
}
|
||||
|
||||
public function reverseTransform($id)
|
||||
{
|
||||
|
@@ -22,7 +22,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class EntityToJsonTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type) {}
|
||||
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly bool $multiple, private readonly string $type)
|
||||
{
|
||||
}
|
||||
|
||||
public function reverseTransform($value)
|
||||
{
|
||||
|
@@ -17,7 +17,9 @@ use Symfony\Component\Form\DataTransformerInterface;
|
||||
|
||||
class MultipleObjectsToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) {}
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a string (id) to an object (item).
|
||||
|
@@ -17,7 +17,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
class ObjectToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null) {}
|
||||
public function __construct(private readonly EntityManagerInterface $em, private readonly ?string $class = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a string (id) to an object.
|
||||
|
@@ -18,7 +18,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
class PostalCodeToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository) {}
|
||||
public function __construct(private readonly PostalCodeRepositoryInterface $postalCodeRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public function reverseTransform($value)
|
||||
{
|
||||
|
@@ -18,7 +18,9 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
class ScopeTransformer implements DataTransformerInterface
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $em) {}
|
||||
public function __construct(private readonly EntityManagerInterface $em)
|
||||
{
|
||||
}
|
||||
|
||||
public function reverseTransform($id)
|
||||
{
|
||||
|
@@ -19,7 +19,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AggregatorType extends AbstractType
|
||||
{
|
||||
public function __construct() {}
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -29,7 +29,9 @@ class ExportType extends AbstractType
|
||||
|
||||
final public const PICK_FORMATTER_KEY = 'pick_formatter';
|
||||
|
||||
public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement) {}
|
||||
public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -22,7 +22,9 @@ class FilterType extends AbstractType
|
||||
{
|
||||
final public const ENABLED_FIELD = 'enabled';
|
||||
|
||||
public function __construct() {}
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -33,7 +33,8 @@ final class PickCenterType extends AbstractType
|
||||
private readonly ExportManager $exportManager,
|
||||
private readonly RegroupmentRepository $regroupmentRepository,
|
||||
private readonly AuthorizationHelperForCurrentUserInterface $authorizationHelper
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -41,7 +41,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
*/
|
||||
final class PickAddressType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator) {}
|
||||
public function __construct(private readonly AddressToIdDataTransformer $addressToIdDataTransformer, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -34,7 +34,9 @@ use function count;
|
||||
*/
|
||||
class PickCenterType extends AbstractType
|
||||
{
|
||||
public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository) {}
|
||||
public function __construct(protected AuthorizationHelperInterface $authorizationHelper, protected Security $security, protected CenterRepository $centerRepository)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* add a data transformer if user can reach only one center.
|
||||
|
@@ -21,7 +21,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PickCivilityType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
|
@@ -19,7 +19,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PickLocationTypeType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
|
@@ -21,7 +21,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PickPostalCodeType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer) {}
|
||||
public function __construct(private readonly PostalCodeToIdTransformer $postalCodeToIdTransformer)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -27,7 +27,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
*/
|
||||
class PickUserDynamicType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer) {}
|
||||
public function __construct(private readonly DenormalizerInterface $denormalizer, private readonly SerializerInterface $serializer, private readonly NormalizerInterface $normalizer)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
@@ -40,6 +42,8 @@ class PickUserDynamicType extends AbstractType
|
||||
$view->vars['types'] = ['user'];
|
||||
$view->vars['uniqid'] = uniqid('pick_user_dyn');
|
||||
$view->vars['suggested'] = [];
|
||||
$view->vars['as_id'] = true === $options['as_id'] ? '1' : '0';
|
||||
$view->vars['submit_on_adding_new_entity'] = true === $options['submit_on_adding_new_entity'] ? '1' : '0';
|
||||
|
||||
foreach ($options['suggested'] as $user) {
|
||||
$view->vars['suggested'][] = $this->normalizer->normalize($user, 'json', ['groups' => 'read']);
|
||||
@@ -52,7 +56,12 @@ class PickUserDynamicType extends AbstractType
|
||||
->setDefault('multiple', false)
|
||||
->setAllowedTypes('multiple', ['bool'])
|
||||
->setDefault('compound', false)
|
||||
->setDefault('suggested', []);
|
||||
->setDefault('suggested', [])
|
||||
// if set to true, only the id will be set inside the content. The denormalization will not work.
|
||||
->setDefault('as_id', false)
|
||||
->setAllowedTypes('as_id', ['bool'])
|
||||
->setDefault('submit_on_adding_new_entity', false)
|
||||
->setAllowedTypes('submit_on_adding_new_entity', ['bool']);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
|
@@ -20,7 +20,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PickUserLocationType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository) {}
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly LocationRepository $locationRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
|
@@ -21,7 +21,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PrivateCommentType extends AbstractType
|
||||
{
|
||||
public function __construct(protected PrivateCommentDataMapper $dataMapper) {}
|
||||
public function __construct(protected PrivateCommentDataMapper $dataMapper)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -43,7 +43,9 @@ class ScopePickerType extends AbstractType
|
||||
private readonly AuthorizationHelperInterface $authorizationHelper,
|
||||
private readonly Security $security,
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
||||
) {}
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -26,7 +26,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
*/
|
||||
class Select2CountryType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
|
||||
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -26,7 +26,9 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
*/
|
||||
class Select2LanguageType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
|
||||
public function __construct(private readonly RequestStack $requestStack, private readonly ObjectManager $em, protected TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -36,7 +36,9 @@ use Symfony\Component\Validator\Constraints\Regex;
|
||||
|
||||
class UserType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@@ -34,7 +34,9 @@ use Symfony\Component\Workflow\Transition;
|
||||
|
||||
class WorkflowStepType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
|
||||
public function __construct(private readonly EntityWorkflowManager $entityWorkflowManager, private readonly Registry $registry, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
Reference in New Issue
Block a user