mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 09:05:01 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -25,7 +25,7 @@ final readonly class FilterOrderGetActiveFilterHelper
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Return all the data required to display the active filters
|
||||
* Return all the data required to display the active filters.
|
||||
*
|
||||
* @return array<array{label: string, value: string, position: string, name: string}>
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ final readonly class FilterOrderGetActiveFilterHelper
|
||||
}
|
||||
|
||||
foreach ($filterOrderHelper->getDateRanges() as $name => ['label' => $label]) {
|
||||
$base = ['position' => FilterOrderPositionEnum::DateRange->value, 'name' => $name, 'label' => (string)$label];
|
||||
$base = ['position' => FilterOrderPositionEnum::DateRange->value, 'name' => $name, 'label' => (string) $label];
|
||||
|
||||
if (null !== ($from = $filterOrderHelper->getDateRangeData($name)['from'] ?? null)) {
|
||||
$result[] = ['value' => $this->translator->trans('filter_order.by_date.From', ['from_date' => $from]), ...$base];
|
||||
@@ -66,7 +66,7 @@ final readonly class FilterOrderGetActiveFilterHelper
|
||||
throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", $selected::class));
|
||||
}
|
||||
|
||||
$value = (string)$selected;
|
||||
$value = (string) $selected;
|
||||
}
|
||||
|
||||
$result[] = ['value' => $this->translator->trans($value), 'label' => $label, 'position' => FilterOrderPositionEnum::EntityChoice->value, 'name' => $name];
|
||||
|
@@ -13,13 +13,10 @@ namespace Chill\MainBundle\Templating\Listing;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\Type\Listing\FilterOrderType;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
use function array_merge;
|
||||
|
||||
final class FilterOrderHelper
|
||||
{
|
||||
private array $checkboxes = [];
|
||||
@@ -78,14 +75,13 @@ final class FilterOrderHelper
|
||||
return $this->entityChoices;
|
||||
}
|
||||
|
||||
public function addUserPicker(string $name, ?string $label = null, array $options = []): self
|
||||
public function addUserPicker(string $name, string $label = null, array $options = []): self
|
||||
{
|
||||
$this->userPickers[$name] = ['label' => $label, 'options' => $options];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function addCheckbox(string $name, array $choices, ?array $default = [], ?array $trans = [], array $options = []): self
|
||||
{
|
||||
if ([] === $trans) {
|
||||
@@ -102,7 +98,7 @@ final class FilterOrderHelper
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addDateRange(string $name, ?string $label = null, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self
|
||||
public function addDateRange(string $name, string $label = null, \DateTimeImmutable $from = null, \DateTimeImmutable $to = null): self
|
||||
{
|
||||
$this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label];
|
||||
|
||||
@@ -112,7 +108,7 @@ final class FilterOrderHelper
|
||||
public function buildForm(): FormInterface
|
||||
{
|
||||
return $this->formFactory
|
||||
->createNamed(self::FORM_NAME, $this->formType, $this->getDefaultData(), array_merge([
|
||||
->createNamed(self::FORM_NAME, $this->formType, $this->getDefaultData(), \array_merge([
|
||||
'helper' => $this,
|
||||
'method' => 'GET',
|
||||
'csrf_protection' => false,
|
||||
@@ -187,7 +183,7 @@ final class FilterOrderHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{to: ?DateTimeImmutable, from: ?DateTimeImmutable}
|
||||
* @return array{to: ?\DateTimeImmutable, from: ?\DateTimeImmutable}
|
||||
*/
|
||||
public function getDateRangeData(string $name): array
|
||||
{
|
||||
@@ -223,7 +219,7 @@ final class FilterOrderHelper
|
||||
'dateRanges' => [],
|
||||
'single_checkboxes' => [],
|
||||
'entity_choices' => [],
|
||||
'user_pickers' => []
|
||||
'user_pickers' => [],
|
||||
];
|
||||
|
||||
if ($this->hasSearchBox()) {
|
||||
|
@@ -11,11 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Templating\Listing;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class FilterOrderHelperBuilder
|
||||
{
|
||||
@@ -66,7 +63,7 @@ class FilterOrderHelperBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addDateRange(string $name, ?string $label = null, ?DateTimeImmutable $from = null, ?DateTimeImmutable $to = null): self
|
||||
public function addDateRange(string $name, string $label = null, \DateTimeImmutable $from = null, \DateTimeImmutable $to = null): self
|
||||
{
|
||||
$this->dateRanges[$name] = ['from' => $from, 'to' => $to, 'label' => $label];
|
||||
|
||||
@@ -80,7 +77,7 @@ class FilterOrderHelperBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addUserPicker(string $name, ?string $label = null, ?array $options = []): self
|
||||
public function addUserPicker(string $name, string $label = null, ?array $options = []): self
|
||||
{
|
||||
$this->userPickers[$name] = ['label' => $label, 'options' => $options];
|
||||
|
||||
@@ -128,7 +125,6 @@ class FilterOrderHelperBuilder
|
||||
$helper->addDateRange($name, $label, $from, $to);
|
||||
}
|
||||
|
||||
|
||||
foreach (
|
||||
$this->userPickers as $name => [
|
||||
'label' => $label,
|
||||
@@ -138,7 +134,6 @@ class FilterOrderHelperBuilder
|
||||
$helper->addUserPicker($name, $label, $options);
|
||||
}
|
||||
|
||||
|
||||
return $helper;
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,6 @@ namespace Chill\MainBundle\Templating\Listing;
|
||||
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface
|
||||
{
|
||||
|
Reference in New Issue
Block a user