From 8d4d8f3a0d850db0f3a58a8a24076c33fde30b2f Mon Sep 17 00:00:00 2001 From: Tchama Date: Mon, 27 Jul 2020 18:00:04 +0200 Subject: [PATCH] sf4, remove deprecated use Symfony\Component\Form\ChoiceList\LazyChoiceList --- Form/ChoiceLoader/PersonChoiceLoader.php | 40 +++++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/Form/ChoiceLoader/PersonChoiceLoader.php b/Form/ChoiceLoader/PersonChoiceLoader.php index 18c7d4a2e..b1cdfee7a 100644 --- a/Form/ChoiceLoader/PersonChoiceLoader.php +++ b/Form/ChoiceLoader/PersonChoiceLoader.php @@ -1,4 +1,5 @@ * @@ -15,31 +16,43 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ + namespace Chill\PersonBundle\Form\ChoiceLoader; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Doctrine\ORM\EntityRepository; -use Symfony\Component\Form\ChoiceList\LazyChoiceList; use Chill\PersonBundle\Entity\Person; /** - * + * Class PersonChoiceLoader * + * @package Chill\PersonBundle\Form\ChoiceLoader * @author Julien Fastré */ class PersonChoiceLoader implements ChoiceLoaderInterface { /** - * * @var EntityRepository */ protected $personRepository; + /** + * @var array + */ protected $lazyLoadedPersons = []; + /** + * @var array + */ protected $centers = []; + /** + * PersonChoiceLoader constructor. + * + * @param EntityRepository $personRepository + * @param array|null $centers + */ public function __construct( EntityRepository $personRepository, array $centers = null @@ -50,11 +63,18 @@ class PersonChoiceLoader implements ChoiceLoaderInterface } } + /** + * @return bool + */ protected function hasCenterFilter() { return count($this->centers) > 0; } - + + /** + * @param null $value + * @return ChoiceListInterface + */ public function loadChoiceList($value = null): ChoiceListInterface { $list = new \Symfony\Component\Form\ChoiceList\ArrayChoiceList( @@ -65,7 +85,12 @@ class PersonChoiceLoader implements ChoiceLoaderInterface return $list; } - + + /** + * @param array $values + * @param null $value + * @return array + */ public function loadChoicesForValues(array $values, $value = null) { $choices = []; @@ -88,6 +113,11 @@ class PersonChoiceLoader implements ChoiceLoaderInterface return $choices; } + /** + * @param array $choices + * @param null $value + * @return array|string[] + */ public function loadValuesForChoices(array $choices, $value = null) { $values = [];