mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix: SA: Fix "...an unused use..." rule.
Also fix a critical bug in `ListPerson.php`. SA stands for Static Analysis.
This commit is contained in:
@@ -1,21 +1,6 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
@@ -29,36 +14,21 @@ use Symfony\Bridge\Twig\TwigEngine;
|
||||
use Chill\MainBundle\Form\Type\Select2ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CustomFieldLongChoice extends AbstractCustomField
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var OptionRepository
|
||||
*/
|
||||
private $optionRepository;
|
||||
private OptionRepository $optionRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
/**
|
||||
* @var TwigEngine
|
||||
*/
|
||||
private $templating;
|
||||
private TwigEngine $templating;
|
||||
|
||||
const KEY = 'key';
|
||||
public const KEY = 'key';
|
||||
|
||||
public function __construct(OptionRepository $optionRepository,
|
||||
public function __construct(
|
||||
OptionRepository $optionRepository,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
TwigEngine $twigEngine)
|
||||
{
|
||||
TwigEngine $twigEngine
|
||||
) {
|
||||
$this->optionRepository = $optionRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->templating = $twigEngine;
|
||||
@@ -76,12 +46,7 @@ class CustomFieldLongChoice extends AbstractCustomField
|
||||
'choice_label' => function(Option $option) use ($translatableStringHelper) {
|
||||
return $translatableStringHelper->localize($option->getText());
|
||||
},
|
||||
'choice_value' => function ($key) use ($entries) {
|
||||
if ($key === NULL) {
|
||||
return null;
|
||||
}
|
||||
return $key->getId();
|
||||
},
|
||||
'choice_value' => static fn (Option $key): ?int => $key === null ? null : $key->getId(),
|
||||
'multiple' => false,
|
||||
'expanded' => false,
|
||||
'required' => $customField->isRequired(),
|
||||
@@ -89,15 +54,16 @@ class CustomFieldLongChoice extends AbstractCustomField
|
||||
'group_by' => function(Option $option) use ($translatableStringHelper) {
|
||||
if ($option->hasParent()) {
|
||||
return $translatableStringHelper->localize($option->getParent()->getText());
|
||||
} else {
|
||||
return $translatableStringHelper->localize($option->getText());
|
||||
}
|
||||
|
||||
return $translatableStringHelper->localize($option->getText());
|
||||
},
|
||||
'label' => $translatableStringHelper->localize($customField->getName())
|
||||
));
|
||||
$builder->get($customField->getSlug())
|
||||
->addModelTransformer(new CustomFieldDataTransformer($this, $customField));
|
||||
|
||||
$builder
|
||||
->get($customField->getSlug())
|
||||
->addModelTransformer(new CustomFieldDataTransformer($this, $customField));
|
||||
}
|
||||
|
||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||
|
Reference in New Issue
Block a user