mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
sf4, remove deprecated use Symfony\Component\Form\ChoiceList\LazyChoiceList
This commit is contained in:
parent
9952a885ed
commit
8d4d8f3a0d
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
|
||||
*
|
||||
@ -15,31 +16,43 @@
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
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é <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
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 = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user