mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
@@ -16,8 +16,6 @@ use Chill\MainBundle\Repository\PostalCodeRepository;
|
||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
|
||||
use function call_user_func;
|
||||
|
||||
/**
|
||||
* Class PostalCodeChoiceLoader.
|
||||
*/
|
||||
@@ -48,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)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -88,7 +86,7 @@ class PostalCodeChoiceLoader implements ChoiceLoaderInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = call_user_func($value, $choice);
|
||||
$id = \call_user_func($value, $choice);
|
||||
$values[] = $id;
|
||||
$this->lazyLoadedPostalCodes[$id] = $choice;
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ namespace Chill\MainBundle\Form\DataMapper;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Iterator;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -26,8 +25,8 @@ use Symfony\Component\Form\FormInterface;
|
||||
class AddressDataMapper implements DataMapperInterface
|
||||
{
|
||||
/**
|
||||
* @param Address $address
|
||||
* @param Iterator $forms
|
||||
* @param Address $address
|
||||
* @param \Iterator $forms
|
||||
*/
|
||||
public function mapDataToForms($address, $forms)
|
||||
{
|
||||
@@ -40,16 +39,16 @@ class AddressDataMapper implements DataMapperInterface
|
||||
}
|
||||
|
||||
foreach ($forms as $key => $form) {
|
||||
/** @var FormInterface $form */
|
||||
/* @var FormInterface $form */
|
||||
switch ($key) {
|
||||
case 'streetAddress1':
|
||||
/** @phpstan-ignore-next-line */
|
||||
/* @phpstan-ignore-next-line */
|
||||
$form->setData($address->getStreetAddress1());
|
||||
|
||||
break;
|
||||
|
||||
case 'streetAddress2':
|
||||
/** @phpstan-ignore-next-line */
|
||||
/* @phpstan-ignore-next-line */
|
||||
$form->setData($address->getStreetAddress2());
|
||||
|
||||
break;
|
||||
@@ -76,8 +75,8 @@ class AddressDataMapper implements DataMapperInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Iterator $forms
|
||||
* @param Address $address
|
||||
* @param \Iterator $forms
|
||||
* @param Address $address
|
||||
*/
|
||||
public function mapFormsToData($forms, &$address)
|
||||
{
|
||||
@@ -94,7 +93,7 @@ class AddressDataMapper implements DataMapperInterface
|
||||
}
|
||||
|
||||
foreach ($forms as $key => $form) {
|
||||
/** @var FormInterface $form */
|
||||
/* @var FormInterface $form */
|
||||
switch ($key) {
|
||||
case 'postCode':
|
||||
if (!$form->getData() instanceof PostalCode && !$isNoAddress) {
|
||||
@@ -112,13 +111,13 @@ class AddressDataMapper implements DataMapperInterface
|
||||
|
||||
return;
|
||||
}
|
||||
/** @phpstan-ignore-next-line */
|
||||
/* @phpstan-ignore-next-line */
|
||||
$address->setStreetAddress1($form->getData());
|
||||
|
||||
break;
|
||||
|
||||
case 'streetAddress2':
|
||||
/** @phpstan-ignore-next-line */
|
||||
/* @phpstan-ignore-next-line */
|
||||
$address->setStreetAddress2($form->getData());
|
||||
|
||||
break;
|
||||
|
@@ -11,14 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Form\DataMapper;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Regroupment;
|
||||
use Chill\MainBundle\Repository\RegroupmentRepository;
|
||||
use Exception;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
|
||||
final readonly class ExportPickCenterDataMapper implements DataMapperInterface
|
||||
{
|
||||
@@ -47,7 +42,7 @@ final readonly class ExportPickCenterDataMapper implements DataMapperInterface
|
||||
$centers[spl_object_hash($center)] = $center;
|
||||
}
|
||||
|
||||
if (array_key_exists('regroupment', $forms)) {
|
||||
if (\array_key_exists('regroupment', $forms)) {
|
||||
/** @var Regroupment $regroupment */
|
||||
foreach ($forms['regroupment']->getData() as $regroupment) {
|
||||
foreach ($regroupment->getCenters() as $center) {
|
||||
|
@@ -38,7 +38,7 @@ class RollingDateDataMapper implements DataMapperInterface
|
||||
$forms = iterator_to_array($forms);
|
||||
|
||||
$viewData = new RollingDate(
|
||||
($forms['roll']->getData() ?? RollingDate::T_TODAY),
|
||||
$forms['roll']->getData() ?? RollingDate::T_TODAY,
|
||||
$forms['fixedDate']->getData()
|
||||
);
|
||||
}
|
||||
|
@@ -18,26 +18,24 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Form\DataTransformer;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use function call_user_func;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class IdToEntityDataTransformer implements DataTransformerInterface
|
||||
{
|
||||
private readonly Closure $getId;
|
||||
private readonly \Closure $getId;
|
||||
|
||||
/**
|
||||
* @param Closure $getId
|
||||
* @param \Closure $getId
|
||||
*/
|
||||
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();
|
||||
}
|
||||
@@ -82,7 +80,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
|
||||
$ids = [];
|
||||
|
||||
foreach ($value as $v) {
|
||||
$ids[] = $id = call_user_func($this->getId, $v);
|
||||
$ids[] = $id = \call_user_func($this->getId, $v);
|
||||
|
||||
if (null === $id) {
|
||||
throw new TransformationFailedException('id is null');
|
||||
@@ -96,7 +94,7 @@ class IdToEntityDataTransformer implements DataTransformerInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
$id = call_user_func($this->getId, $value);
|
||||
$id = \call_user_func($this->getId, $value);
|
||||
|
||||
if (null === $id) {
|
||||
throw new TransformationFailedException('id is null');
|
||||
|
@@ -18,10 +18,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use function array_combine;
|
||||
use function array_merge;
|
||||
use function count;
|
||||
|
||||
class PermissionsGroupType extends AbstractType
|
||||
{
|
||||
final public const FLAG_SCOPE = 'permissions_group';
|
||||
@@ -43,10 +39,10 @@ class PermissionsGroupType extends AbstractType
|
||||
|
||||
$flags = $this->getFlags();
|
||||
|
||||
if (count($flags) > 0) {
|
||||
if (\count($flags) > 0) {
|
||||
$builder
|
||||
->add('flags', ChoiceType::class, [
|
||||
'choices' => array_combine($flags, $flags),
|
||||
'choices' => \array_combine($flags, $flags),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'required' => false,
|
||||
@@ -77,7 +73,7 @@ class PermissionsGroupType extends AbstractType
|
||||
$flags = [];
|
||||
|
||||
foreach ($this->flagProviders as $flagProvider) {
|
||||
$flags = array_merge($flags, $flagProvider->getPermissionsGroupFlags());
|
||||
$flags = \array_merge($flags, $flagProvider->getPermissionsGroupFlags());
|
||||
}
|
||||
|
||||
return $flags;
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use DateTime;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
@@ -47,7 +46,7 @@ class CommentType extends AbstractType
|
||||
$comment = $event->getData() ?? ['comment' => ''];
|
||||
|
||||
if (null !== $data && $data->getComment() !== $comment['comment']) {
|
||||
$data->setDate(new DateTime());
|
||||
$data->setDate(new \DateTime());
|
||||
$data->setUserId($this->user->getId());
|
||||
$event->getForm()->setData($data);
|
||||
}
|
||||
|
@@ -20,8 +20,6 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Form to Edit/create a role scope. If the role scope does not
|
||||
* exists in the database, he is generated.
|
||||
@@ -55,7 +53,7 @@ class ComposedRoleScopeType extends AbstractType
|
||||
$translatableStringHelper = $this->translatableStringHelper;
|
||||
$rolesWithoutScopes = $this->rolesWithoutScope;
|
||||
|
||||
//build roles
|
||||
// build roles
|
||||
$values = [];
|
||||
|
||||
foreach ($this->roles as $role) {
|
||||
@@ -67,7 +65,7 @@ class ComposedRoleScopeType extends AbstractType
|
||||
'choices' => array_combine(array_values($values), array_keys($values)),
|
||||
'placeholder' => 'Choose amongst roles',
|
||||
'choice_attr' => static function ($role) use ($rolesWithoutScopes) {
|
||||
if (in_array($role, $rolesWithoutScopes, true)) {
|
||||
if (\in_array($role, $rolesWithoutScopes, true)) {
|
||||
return ['data-has-scope' => '0'];
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,6 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Traversable;
|
||||
|
||||
use function count;
|
||||
|
||||
class CenterTransformer implements DataTransformerInterface
|
||||
{
|
||||
@@ -47,11 +44,8 @@ class CenterTransformer implements DataTransformerInterface
|
||||
->centerRepository
|
||||
->findBy(['id' => $ids]);
|
||||
|
||||
if ([] === $centers || count($ids) > count($centers)) {
|
||||
throw new TransformationFailedException(sprintf(
|
||||
'No center found for one of those ids: %s',
|
||||
implode(',', $ids)
|
||||
));
|
||||
if ([] === $centers || \count($ids) > \count($centers)) {
|
||||
throw new TransformationFailedException(sprintf('No center found for one of those ids: %s', implode(',', $ids)));
|
||||
}
|
||||
|
||||
if ($this->multiple) {
|
||||
@@ -69,7 +63,7 @@ class CenterTransformer implements DataTransformerInterface
|
||||
|
||||
if ($this->multiple) {
|
||||
if (!is_iterable($center)) {
|
||||
throw new UnexpectedTypeException($center, Traversable::class);
|
||||
throw new UnexpectedTypeException($center, \Traversable::class);
|
||||
}
|
||||
$ids = [];
|
||||
|
||||
|
@@ -11,8 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\DataTransformer;
|
||||
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
@@ -25,16 +23,12 @@ class DateIntervalTransformer implements DataTransformerInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
$string = 'P' . $value['n'] . $value['unit'];
|
||||
$string = 'P'.$value['n'].$value['unit'];
|
||||
|
||||
try {
|
||||
return new DateInterval($string);
|
||||
} catch (Exception $e) {
|
||||
throw new TransformationFailedException(
|
||||
'Could not transform value into DateInterval',
|
||||
1542,
|
||||
$e
|
||||
);
|
||||
return new \DateInterval($string);
|
||||
} catch (\Exception $e) {
|
||||
throw new TransformationFailedException('Could not transform value into DateInterval', 1542, $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +38,13 @@ class DateIntervalTransformer implements DataTransformerInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$value instanceof DateInterval) {
|
||||
throw new UnexpectedTypeException($value, DateInterval::class);
|
||||
if (!$value instanceof \DateInterval) {
|
||||
throw new UnexpectedTypeException($value, \DateInterval::class);
|
||||
}
|
||||
|
||||
if (0 < $value->d) {
|
||||
// we check for weeks (weeks are converted to 7 days)
|
||||
if ($value->d % 7 === 0) {
|
||||
if (0 === $value->d % 7) {
|
||||
return [
|
||||
'n' => $value->d / 7,
|
||||
'unit' => 'W',
|
||||
@@ -77,8 +71,6 @@ class DateIntervalTransformer implements DataTransformerInterface
|
||||
];
|
||||
}
|
||||
|
||||
throw new TransformationFailedException(
|
||||
'The date interval does not contains any days, months or years.'
|
||||
);
|
||||
throw new TransformationFailedException('The date interval does not contains any days, months or years.');
|
||||
}
|
||||
}
|
||||
|
@@ -19,9 +19,6 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
use function array_key_exists;
|
||||
|
||||
class EntityToJsonTransformer implements DataTransformerInterface
|
||||
{
|
||||
@@ -29,7 +26,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
|
||||
public function reverseTransform($value)
|
||||
{
|
||||
if ("" === $value) {
|
||||
if ('' === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -65,11 +62,11 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
|
||||
private function denormalizeOne(array $item)
|
||||
{
|
||||
if (!array_key_exists('type', $item)) {
|
||||
if (!\array_key_exists('type', $item)) {
|
||||
throw new TransformationFailedException('the key "type" is missing on element');
|
||||
}
|
||||
|
||||
if (!array_key_exists('id', $item)) {
|
||||
if (!\array_key_exists('id', $item)) {
|
||||
throw new TransformationFailedException('the key "id" is missing on element');
|
||||
}
|
||||
|
||||
@@ -77,7 +74,7 @@ class EntityToJsonTransformer implements DataTransformerInterface
|
||||
'user' => User::class,
|
||||
'person' => Person::class,
|
||||
'thirdparty' => ThirdParty::class,
|
||||
default => throw new UnexpectedValueException('This type is not supported'),
|
||||
default => throw new \UnexpectedValueException('This type is not supported'),
|
||||
};
|
||||
|
||||
return
|
||||
|
@@ -21,8 +21,6 @@ class MultipleObjectsToIdTransformer implements DataTransformerInterface
|
||||
|
||||
/**
|
||||
* Transforms a string (id) to an object (item).
|
||||
*
|
||||
* @param mixed $array
|
||||
*/
|
||||
public function reverseTransform($array)
|
||||
{
|
||||
@@ -49,7 +47,7 @@ class MultipleObjectsToIdTransformer implements DataTransformerInterface
|
||||
$ret = [];
|
||||
|
||||
foreach ($array as $el) {
|
||||
$ret[] = ($el->getId());
|
||||
$ret[] = $el->getId();
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
@@ -22,9 +22,9 @@ class ObjectToIdTransformer implements DataTransformerInterface
|
||||
/**
|
||||
* Transforms a string (id) to an object.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id
|
||||
*
|
||||
* @throws TransformationFailedException if object is not found.
|
||||
* @throws TransformationFailedException if object is not found
|
||||
*/
|
||||
public function reverseTransform($id): ?object
|
||||
{
|
||||
@@ -46,8 +46,6 @@ class ObjectToIdTransformer implements DataTransformerInterface
|
||||
/**
|
||||
* Transforms an object to a string (id).
|
||||
*
|
||||
* @param mixed $object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function transform($object)
|
||||
|
@@ -15,8 +15,6 @@ use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use function gettype;
|
||||
use function is_int;
|
||||
|
||||
class PostalCodeToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
@@ -28,8 +26,8 @@ class PostalCodeToIdTransformer implements DataTransformerInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_int((int) $value)) {
|
||||
throw new TransformationFailedException('Cannot transform ' . gettype($value));
|
||||
if (!\is_int((int) $value)) {
|
||||
throw new TransformationFailedException('Cannot transform '.\gettype($value));
|
||||
}
|
||||
|
||||
return $this->postalCodeRepository->find((int) $value);
|
||||
@@ -45,6 +43,6 @@ class PostalCodeToIdTransformer implements DataTransformerInterface
|
||||
return $value->getId();
|
||||
}
|
||||
|
||||
throw new TransformationFailedException('Could not reverseTransform ' . gettype($value));
|
||||
throw new TransformationFailedException('Could not reverseTransform '.\gettype($value));
|
||||
}
|
||||
}
|
||||
|
@@ -32,8 +32,7 @@ class ScopeTransformer implements DataTransformerInterface
|
||||
->find($id);
|
||||
|
||||
if (null === $scope) {
|
||||
throw new TransformationFailedException(sprintf('The scope with id '
|
||||
. "'%d' were not found", $id));
|
||||
throw new TransformationFailedException(sprintf('The scope with id '."'%d' were not found", $id));
|
||||
}
|
||||
|
||||
return $scope;
|
||||
|
@@ -20,12 +20,6 @@ use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
|
||||
use function array_diff;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function implode;
|
||||
use function is_array;
|
||||
|
||||
/**
|
||||
* Show a dateInterval type.
|
||||
*
|
||||
@@ -86,21 +80,17 @@ class DateIntervalType extends AbstractType
|
||||
'Years' => 'Y',
|
||||
])
|
||||
->setAllowedValues('unit_choices', static function ($values) {
|
||||
if (false === is_array($values)) {
|
||||
if (false === \is_array($values)) {
|
||||
throw new InvalidOptionsException('The value `unit_choice` should be an array');
|
||||
}
|
||||
|
||||
$diff = array_diff(array_values($values), ['D', 'W', 'M', 'Y']);
|
||||
$diff = \array_diff(\array_values($values), ['D', 'W', 'M', 'Y']);
|
||||
|
||||
if (count($diff) === 0) {
|
||||
if (0 === \count($diff)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new InvalidOptionsException(sprintf(
|
||||
'The values of the '
|
||||
. "units should be 'D', 'W', 'M', 'Y', those are invalid: %s",
|
||||
implode(', ', $diff)
|
||||
));
|
||||
throw new InvalidOptionsException(sprintf('The values of the '."units should be 'D', 'W', 'M', 'Y', those are invalid: %s", \implode(', ', $diff)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -49,14 +49,14 @@ class ExportType extends AbstractType
|
||||
];
|
||||
|
||||
// add a contraint if required by export
|
||||
$exportBuilder = $builder->create(self::EXPORT_KEY/*, FormType::class, $exportOptions*/);
|
||||
$exportBuilder = $builder->create(self::EXPORT_KEY/* , FormType::class, $exportOptions */);
|
||||
|
||||
$export->buildForm($exportBuilder);
|
||||
|
||||
$builder->add($exportBuilder, null, $exportOptions);
|
||||
|
||||
if ($export instanceof \Chill\MainBundle\Export\ExportInterface) {
|
||||
//add filters
|
||||
// add filters
|
||||
$filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']);
|
||||
$filterBuilder = $builder->create(self::FILTER_KEY, FormType::class, ['compound' => true]);
|
||||
|
||||
@@ -73,7 +73,7 @@ class ExportType extends AbstractType
|
||||
|
||||
$builder->add($filterBuilder);
|
||||
|
||||
//add aggregators
|
||||
// add aggregators
|
||||
$aggregators = $this->exportManager
|
||||
->getAggregatorsApplyingOn($export, $options['picked_centers']);
|
||||
$aggregatorBuilder = $builder->create(
|
||||
@@ -115,7 +115,7 @@ class ExportType extends AbstractType
|
||||
->setAllowedTypes('export_alias', ['string'])
|
||||
->setDefault('compound', true)
|
||||
->setDefault('constraints', [
|
||||
//new \Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraint()
|
||||
// new \Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraint()
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -17,15 +17,10 @@ use Chill\MainBundle\Export\ExportManager;
|
||||
use Chill\MainBundle\Form\DataMapper\ExportPickCenterDataMapper;
|
||||
use Chill\MainBundle\Repository\RegroupmentRepository;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Pick centers amongst available centers for the user.
|
||||
@@ -61,7 +56,7 @@ final class PickCenterType extends AbstractType
|
||||
'choice_label' => static fn (Center $c) => $c->getName(),
|
||||
]);
|
||||
|
||||
if (count($this->regroupmentRepository->findAllActive()) > 0) {
|
||||
if (\count($this->regroupmentRepository->findAllActive()) > 0) {
|
||||
$builder->add('regroupment', EntityType::class, [
|
||||
'class' => Regroupment::class,
|
||||
'label' => 'regroupment',
|
||||
|
@@ -35,7 +35,7 @@ class PickFormatterType extends AbstractType
|
||||
$allowedFormatters = $this->exportManager
|
||||
->getFormattersByTypes($export->getAllowedFormattersTypes());
|
||||
|
||||
//build choices
|
||||
// build choices
|
||||
$choices = [];
|
||||
|
||||
foreach ($allowedFormatters as $alias => $formatter) {
|
||||
|
@@ -17,16 +17,10 @@ use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SearchType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
use function array_combine;
|
||||
use function array_map;
|
||||
use function count;
|
||||
|
||||
final class FilterOrderType extends \Symfony\Component\Form\AbstractType
|
||||
{
|
||||
@@ -41,7 +35,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'placeholder' => 'filter_order.Search',
|
||||
]
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -57,7 +51,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
if (0 < count($helper->getCheckboxes())) {
|
||||
if (0 < \count($helper->getCheckboxes())) {
|
||||
$builder->add($checkboxesBuilder);
|
||||
}
|
||||
|
||||
@@ -80,7 +74,7 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
|
||||
$builder->add($entityChoicesBuilder);
|
||||
}
|
||||
|
||||
if (0 < count($helper->getDateRanges())) {
|
||||
if (0 < \count($helper->getDateRanges())) {
|
||||
$dateRangesBuilder = $builder->create('dateRanges', null, ['compound' => true]);
|
||||
|
||||
foreach ($helper->getDateRanges() as $name => $opts) {
|
||||
@@ -139,8 +133,8 @@ final class FilterOrderType extends \Symfony\Component\Form\AbstractType
|
||||
|
||||
public static function buildCheckboxChoices(array $choices, array $trans = []): array
|
||||
{
|
||||
return array_combine(
|
||||
array_map(static function ($c, $t) {
|
||||
return \array_combine(
|
||||
\array_map(static function ($c, $t) {
|
||||
if (null !== $t) {
|
||||
return $t;
|
||||
}
|
||||
|
@@ -21,8 +21,6 @@ use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use function uniqid;
|
||||
|
||||
/**
|
||||
* Form type for picking an address.
|
||||
*
|
||||
@@ -52,7 +50,7 @@ final class PickAddressType extends AbstractType
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['uniqid'] = $view->vars['attr']['data-input-address'] = uniqid('input_address_');
|
||||
$view->vars['uniqid'] = $view->vars['attr']['data-input-address'] = \uniqid('input_address_');
|
||||
$view->vars['attr']['data-use-valid-from'] = (int) $options['use_valid_from'];
|
||||
$view->vars['attr']['data-use-valid-to'] = (int) $options['use_valid_to'];
|
||||
$view->vars['attr']['data-button-text-create'] = $this->translator->trans($options['button_text_create']);
|
||||
|
@@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
||||
use Chill\MainBundle\Repository\CenterRepository;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
@@ -25,9 +24,6 @@ use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
use function array_merge;
|
||||
use function array_values;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
@@ -49,7 +45,7 @@ class PickCenterType extends AbstractType
|
||||
|
||||
$centersActive = array_filter($centers, fn (Center $c) => $c->getIsActive());
|
||||
|
||||
if (count($centers) <= 1) {
|
||||
if (\count($centers) <= 1) {
|
||||
$multiple = $options['choice_options']['multiple'] ?? false;
|
||||
$builder->add('center', HiddenType::class);
|
||||
$builder->get('center')->addModelTransformer(
|
||||
@@ -59,7 +55,7 @@ class PickCenterType extends AbstractType
|
||||
$builder->add(
|
||||
'center',
|
||||
EntityType::class,
|
||||
array_merge(
|
||||
\array_merge(
|
||||
$options['choice_options'],
|
||||
[
|
||||
'class' => Center::class,
|
||||
@@ -84,7 +80,7 @@ class PickCenterType extends AbstractType
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['is_hidden'] = count($this->getReachableCenters(
|
||||
$view->vars['is_hidden'] = \count($this->getReachableCenters(
|
||||
$options['role'],
|
||||
$options['scopes']
|
||||
)) <= 1;
|
||||
@@ -95,9 +91,9 @@ class PickCenterType extends AbstractType
|
||||
*
|
||||
* Return a 'choice' field if more than one center is available.
|
||||
*
|
||||
* @throws RuntimeException if the user is not associated with any center
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException if the user is not associated with any center
|
||||
*/
|
||||
/*
|
||||
public function getParent()
|
||||
@@ -134,7 +130,7 @@ class PickCenterType extends AbstractType
|
||||
|
||||
private function getReachableCenters(string $role, iterable $scopes): array
|
||||
{
|
||||
if (0 < count($scopes)) {
|
||||
if (0 < \count($scopes)) {
|
||||
$centers = [];
|
||||
|
||||
foreach ($scopes as $scope) {
|
||||
@@ -146,7 +142,7 @@ class PickCenterType extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($centers);
|
||||
return \array_values($centers);
|
||||
}
|
||||
|
||||
return $this->authorizationHelper
|
||||
|
@@ -29,7 +29,7 @@ class PickRollingDateType extends AbstractType
|
||||
$builder
|
||||
->add('roll', ChoiceType::class, [
|
||||
'choices' => array_combine(
|
||||
array_map(static fn (string $item) => 'rolling_date.' . $item, RollingDate::ALL_T),
|
||||
array_map(static fn (string $item) => 'rolling_date.'.$item, RollingDate::ALL_T),
|
||||
RollingDate::ALL_T
|
||||
),
|
||||
'multiple' => false,
|
||||
|
@@ -29,7 +29,7 @@ class PickUserLocationType extends AbstractType
|
||||
'class' => Location::class,
|
||||
'choices' => $this->locationRepository->findByPublicLocations(),
|
||||
'choice_label' => fn (Location $entity) => $entity->getName() ?
|
||||
$entity->getName() . ' (' . $this->translatableStringHelper->localize($entity->getLocationType()->getTitle()) . ')' :
|
||||
$entity->getName().' ('.$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()).')' :
|
||||
$this->translatableStringHelper->localize($entity->getLocationType()->getTitle()),
|
||||
'placeholder' => 'Pick a location',
|
||||
'required' => false,
|
||||
|
@@ -77,8 +77,8 @@ class PostalCodeType extends AbstractType
|
||||
$helper = $this->translatableStringHelper;
|
||||
$resolver
|
||||
->setDefault('class', PostalCode::class)
|
||||
->setDefault('choice_label', static fn (PostalCode $code) => $code->getCode() . ' ' . $code->getName() . ' [' .
|
||||
$helper->localize($code->getCountry()->getName()) . ']')
|
||||
->setDefault('choice_label', static fn (PostalCode $code) => $code->getCode().' '.$code->getName().' ['.
|
||||
$helper->localize($code->getCountry()->getName()).']')
|
||||
->setDefault('choice_loader', $this->choiceLoader)
|
||||
->setDefault('placeholder', 'Select a postal code');
|
||||
}
|
||||
|
@@ -13,14 +13,11 @@ namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||
use Chill\MainBundle\Form\DataMapper\PrivateCommentDataMapper;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class PrivateCommentType extends AbstractType
|
||||
{
|
||||
|
@@ -17,7 +17,6 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\DataMapper\ScopePickerDataMapper;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
@@ -27,9 +26,7 @@ use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Allow to pick amongst available scope for the current
|
||||
@@ -57,11 +54,11 @@ class ScopePickerType extends AbstractType
|
||||
)
|
||||
);
|
||||
|
||||
if (0 === count($items)) {
|
||||
throw new RuntimeException('no scopes are reachable. This form should not be shown to user');
|
||||
if (0 === \count($items)) {
|
||||
throw new \RuntimeException('no scopes are reachable. This form should not be shown to user');
|
||||
}
|
||||
|
||||
if (1 !== count($items)) {
|
||||
if (1 !== \count($items)) {
|
||||
$builder->add('scope', EntityType::class, [
|
||||
'class' => Scope::class,
|
||||
'placeholder' => 'Choose the circle',
|
||||
|
@@ -21,9 +21,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use const SORT_FLAG_CASE;
|
||||
use const SORT_STRING;
|
||||
|
||||
/**
|
||||
* Extends choice to allow adding select2 library on widget.
|
||||
*/
|
||||
@@ -56,7 +53,7 @@ class Select2CountryType extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
||||
asort($choices, \SORT_STRING | \SORT_FLAG_CASE);
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => \Chill\MainBundle\Entity\Country::class,
|
||||
|
@@ -21,9 +21,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
use const SORT_FLAG_CASE;
|
||||
use const SORT_STRING;
|
||||
|
||||
/**
|
||||
* Extends choice to allow adding select2 library on widget for languages (multiple).
|
||||
*/
|
||||
@@ -52,7 +49,7 @@ class Select2LanguageType extends AbstractType
|
||||
$preferredChoices[$l] = $choices[$l];
|
||||
}
|
||||
|
||||
asort($choices, SORT_STRING | SORT_FLAG_CASE);
|
||||
asort($choices, \SORT_STRING | \SORT_FLAG_CASE);
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => \Chill\MainBundle\Entity\Language::class,
|
||||
|
@@ -20,8 +20,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class TranslatableStringFormType extends AbstractType
|
||||
{
|
||||
// The langauges availaible
|
||||
@@ -39,11 +37,11 @@ class TranslatableStringFormType extends AbstractType
|
||||
$builder->add(
|
||||
$lang,
|
||||
TextType::class,
|
||||
['required' => (in_array(
|
||||
['required' => \in_array(
|
||||
$lang,
|
||||
$this->frameworkTranslatorFallback,
|
||||
true
|
||||
))]
|
||||
)]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -67,8 +67,8 @@ class UserPasswordType extends AbstractType
|
||||
new Regex([
|
||||
'pattern' => "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/",
|
||||
'message' => 'The password must contains one letter, one '
|
||||
. 'capitalized letter, one number and one special character '
|
||||
. "as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.",
|
||||
.'capitalized letter, one number and one special character '
|
||||
."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.",
|
||||
]),
|
||||
],
|
||||
])
|
||||
|
@@ -88,7 +88,7 @@ class UserType extends AbstractType
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a location',
|
||||
'class' => Location::class,
|
||||
'choice_label' => fn (Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ' - ' . $l->getName(),
|
||||
'choice_label' => fn (Location $l) => $this->translatableStringHelper->localize($l->getLocationType()->getTitle()).' - '.$l->getName(),
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('l');
|
||||
$qb->orderBy('l.locationType');
|
||||
@@ -126,8 +126,8 @@ class UserType extends AbstractType
|
||||
new Regex([
|
||||
'pattern' => "/((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%!,;:+\"'-\\/{}~=µ\\(\\)£]).{6,})/",
|
||||
'message' => 'The password must contains one letter, one '
|
||||
. 'capitalized letter, one number and one special character '
|
||||
. "as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.",
|
||||
.'capitalized letter, one number and one special character '
|
||||
."as *[@#$%!,;:+\"'-/{}~=µ()£]). Other characters are allowed.",
|
||||
]),
|
||||
],
|
||||
]);
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Form\Type\ChillTextareaType;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
@@ -32,7 +31,6 @@ use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Component\Workflow\Transition;
|
||||
use function array_key_exists;
|
||||
|
||||
class WorkflowStepType extends AbstractType
|
||||
{
|
||||
@@ -49,7 +47,7 @@ class WorkflowStepType extends AbstractType
|
||||
|
||||
if (true === $options['transition']) {
|
||||
if (null === $options['entity_workflow']) {
|
||||
throw new LogicException('if transition is true, entity_workflow should be defined');
|
||||
throw new \LogicException('if transition is true, entity_workflow should be defined');
|
||||
}
|
||||
|
||||
$transitions = $this->registry
|
||||
@@ -64,7 +62,7 @@ class WorkflowStepType extends AbstractType
|
||||
$transitions
|
||||
);
|
||||
|
||||
if (array_key_exists('validationFilterInputLabels', $placeMetadata)) {
|
||||
if (\array_key_exists('validationFilterInputLabels', $placeMetadata)) {
|
||||
$inputLabels = $placeMetadata['validationFilterInputLabels'];
|
||||
|
||||
$builder->add('transitionFilter', ChoiceType::class, [
|
||||
@@ -96,7 +94,7 @@ class WorkflowStepType extends AbstractType
|
||||
'choice_label' => function (Transition $transition) use ($workflow) {
|
||||
$meta = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
|
||||
if (array_key_exists('label', $meta)) {
|
||||
if (\array_key_exists('label', $meta)) {
|
||||
return $this->translatableStringHelper->localize($meta['label']);
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ class WorkflowStepType extends AbstractType
|
||||
|
||||
$metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
|
||||
if (array_key_exists('isForward', $metadata)) {
|
||||
if (\array_key_exists('isForward', $metadata)) {
|
||||
if ($metadata['isForward']) {
|
||||
$isForward = 'forward';
|
||||
} else {
|
||||
@@ -120,7 +118,7 @@ class WorkflowStepType extends AbstractType
|
||||
$meta = $workflow->getMetadataStore()->getPlaceMetadata($to);
|
||||
|
||||
if (
|
||||
!array_key_exists('isFinal', $meta) || false === $meta['isFinal']
|
||||
!\array_key_exists('isFinal', $meta) || false === $meta['isFinal']
|
||||
) {
|
||||
$toFinal = false;
|
||||
}
|
||||
@@ -209,7 +207,7 @@ class WorkflowStepType extends AbstractType
|
||||
$meta = $workflow->getMetadataStore()->getPlaceMetadata($to);
|
||||
|
||||
if (
|
||||
!array_key_exists('isFinal', $meta) || false === $meta['isFinal']
|
||||
!\array_key_exists('isFinal', $meta) || false === $meta['isFinal']
|
||||
) {
|
||||
$toFinal = false;
|
||||
}
|
||||
@@ -239,7 +237,7 @@ class WorkflowStepType extends AbstractType
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user