Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -19,19 +19,10 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Support Remote-API calls for Entity select-boxes.
*/
class SelectWithApiDataExtension extends AbstractTypeExtension
final class SelectWithApiDataExtension extends AbstractTypeExtension
{
/**
* @var UrlGeneratorInterface
*/
private $router;
/**
* @param UrlGeneratorInterface $router
*/
public function __construct(UrlGeneratorInterface $router)
public function __construct(private UrlGeneratorInterface $router)
{
$this->router = $router;
}
public static function getExtendedTypes(): iterable
@@ -44,7 +35,7 @@ class SelectWithApiDataExtension extends AbstractTypeExtension
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if (!isset($options['api_data'])) {
return;
@@ -56,6 +47,12 @@ class SelectWithApiDataExtension extends AbstractTypeExtension
throw new \InvalidArgumentException('Option "api_data" must be an array for form "' . $form->getName() . '"');
}
if (isset($apiData['create'])) {
$view->vars['attr'] = array_merge($view->vars['attr'], [
'data-create' => $this->router->generate($apiData['create']),
]);
}
if (!isset($apiData['select'])) {
return;
}
@@ -93,12 +90,15 @@ class SelectWithApiDataExtension extends AbstractTypeExtension
'data-empty-url' => $this->router->generate($apiData['route'], $apiData['empty_route_params']),
]);
}
if (isset($apiData['reload'])) {
$view->vars['attr'] = array_merge($view->vars['attr'], [
'data-reload' => $this->router->generate($apiData['reload']),
]);
}
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefined(['api_data']);
$resolver->setAllowedTypes('api_data', 'array');