Release 2.13 (#4659)

This commit is contained in:
Kevin Papst
2024-03-10 15:35:59 +01:00
committed by GitHub
parent a78e8ed8c4
commit dee90bb15e
79 changed files with 1019 additions and 932 deletions

View File

@@ -9,9 +9,12 @@
namespace App\Form\Toolbar;
use App\Repository\CustomerRepository;
use App\Repository\Query\CustomerQuery;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Intl\Countries;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
@@ -22,9 +25,38 @@ final class CustomerToolbarForm extends AbstractType
{
use ToolbarFormTrait;
public function __construct(private readonly CustomerRepository $customerRepository)
{
}
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$this->addSearchTermInputField($builder);
// fetch countries
$qb = $this->customerRepository->createQueryBuilder('c');
$qb
->select('c.country')
->distinct(true);
$countries = $qb->getQuery()->getSingleColumnResult();
$choices = [];
foreach ($countries as $country) {
if (\is_string($country) && \is_string($options['locale'])) {
$choices[$country] = Countries::getName($country, $options['locale']);
}
}
if (\count($choices) > 0) {
$choices = array_flip($choices);
ksort($choices);
$builder->add('country', ChoiceType::class, [
'label' => 'country',
'choices' => $choices,
'required' => false,
]);
}
$this->addVisibilityChoice($builder);
$this->addPageSizeChoice($builder);
$this->addHiddenPagination($builder);
@@ -37,6 +69,8 @@ final class CustomerToolbarForm extends AbstractType
$resolver->setDefaults([
'data_class' => CustomerQuery::class,
'csrf_protection' => false,
'locale' => locale_get_default(),
]);
$resolver->setAllowedTypes('locale', ['string']);
}
}

View File

@@ -19,8 +19,8 @@ final class TagsType extends AbstractType
private ?int $count = null;
public function __construct(
private AuthorizationCheckerInterface $auth,
private TagRepository $repository
private readonly AuthorizationCheckerInterface $auth,
private readonly TagRepository $repository
) {
}