* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\ChoiceList\Loader; use Symfony\Component\Form\ChoiceList\ArrayChoiceList; /** * Loads an {@link ArrayChoiceList} instance from a callable returning an array of choices. * * @author Jules Pietri */ class CallbackChoiceLoader implements ChoiceLoaderInterface { private $callback; /** * The loaded choice list. * * @var ArrayChoiceList */ private $choiceList; /** * @param callable $callback The callable returning an array of choices */ public function __construct(callable $callback) { $this->callback = $callback; } /** * {@inheritdoc} */ public function loadChoiceList($value = null) { if (null !== $this->choiceList) { return $this->choiceList; } return $this->choiceList = new ArrayChoiceList(call_user_func($this->callback), $value); } /** * {@inheritdoc} */ public function loadChoicesForValues(array $values, $value = null) { // Optimize if (empty($values)) { return array(); } return $this->loadChoiceList($value)->getChoicesForValues($values); } /** * {@inheritdoc} */ public function loadValuesForChoices(array $choices, $value = null) { // Optimize if (empty($choices)) { return array(); } return $this->loadChoiceList($value)->getValuesForChoices($choices); } } __halt_compiler();----SIGNATURE:----ZpPQ4owXNY/QvhmC3VfKzqvr85y87VSAYZFLEPISBujDqIqKOm+698mfVdBXb9CcoA0m5tmZsU3nCKwhDZFZ9MyRaSJpOdc9Tj7yVXH2tr7K0hNtPShZUr0ukw78fzSLXFU+RrPUhkYVsDKXfUkeDPoG9CytXD+NPtJuKeZID9IpG5LokafGmKIhHOUy+wumk8iubSw6TKYLkjzF5yjFBbI4po6muumL+iBo6wupB0196WnRLDcvUxGWaKFnqAX48N6eMuE6yJQT/YNeJ+wNR9VPuDDS+aEWgQG+Q5ngh2gsBVN+mMoent7pV2iTPMdZFpegNNlaHI2LupaKgpyMjesawSUwa18YUwC2MVzPNtH9GQNXHKC5MvNl8YCOHbE4+rEClpuicl2ueMyC/ryxmjCZeNf+TRbXSj4PQiSBymwCo/uUv8T8wFByKoEKclevj/4eK88A++GiQHV6ZR9whzAxKjZ9oQCnObuiGww4llDU3L2hJ6n4cTMq5vGQEQefqFTKlFnwr4SRPaBrlwtnRDAkWvqIXLzmm5oMuoimF8uDGCEY82ZodkOS71nqPLioX5TI/A+ewYg8nk4nwernYOIc2lyxaOHytCJa6oM8+LfxJ1/AFhILAlSa4kf/t1mwJkyUeAM0azdelM1UFNq5dHtDc+K40+Ts4yEP0N+EFAw=----ATTACHMENT:----NTIxNTc4MDkzNDcxNjg5MiA3MDkyMzUwOTU1NTkzNTE0IDE5Nzk3ODg1NjkwMjE2NQ==