public function configureOptions(OptionsResolver $resolver)
    {
        $choiceListCache =& $this->choiceListCache;
        $choiceListFactory = $this->choiceListFactory;
        $entityManager = $this->entityManager;

        $choiceLoader = function (Options $options) use (&$choiceListCache, $choiceListFactory, $entityManager) {
            // Support for closures
            $propertyHash = is_object($options['choice_label'])
                ? spl_object_hash($options['choice_label'])
                : $options['choice_label'];
            $iteratorHash = is_object($options['iterator'])
                ? spl_object_hash($options['iterator'])
                : $options['iterator'];

            $preferredChoiceHashes = $options['preferred_choices'];

            if (is_array($preferredChoiceHashes)) {
                array_walk_recursive($preferredChoiceHashes, function (&$value) {
                    $value = spl_object_hash($value);
                });
            }

            // Support for closures
            $groupByHash = is_object($options['group_by'])
                ? spl_object_hash($options['group_by'])
                : $options['group_by'];

            $hash = md5(json_encode(array(
                spl_object_hash($entityManager),
                $options['model_class_name'],
                $options['selector_class_name'],
                $propertyHash,
                $preferredChoiceHashes,
                $groupByHash,
                $iteratorHash,
            )));

            if (!isset($choiceListCache[$hash])) {
                $choiceListCache[$hash] = new ChoiceLoader(
                    $entityManager,
                    $options['model_class_name'],
                    $options['selector_class_name'],
                    $options['choice_label'],
                    $options['iterator'],
                    $options['preferred_choices'],
                    $options['group_by'],
                    $choiceListFactory
                );
            }

            return $choiceListCache[$hash];
        };

        $resolver->setDefaults(array(
            'em'                => null,
            'query_builder'     => null,
            'choices'           => array(),
            'choice_loader'     => $choiceLoader,
            'group_by'          => null,
            'iterator'          => null,
            'model_class_name'  => null,
            'selector_class_name' => null,
            //'choices_as_values' => true,
        ));

        $resolver->setRequired(array('model_class_name'));

        $resolver->setAllowedTypes('iterator', array('null', 'Yucca\Component\Iterator\Iterator', 'array'));
    }
public function configureOptions(OptionsResolver $resolver)
    {
        $choiceListCache =& $this->choiceListCache;
        $choiceListFactory = $this->choiceListFactory;
        $entityManager = $this->entityManager;

        $choiceLoader = function (Options $options) use (&$choiceListCache, $choiceListFactory, $entityManager) {
            // Support for closures
            $propertyHash = is_object($options['choice_label'])
                ? spl_object_hash($options['choice_label'])
                : $options['choice_label'];
            $iteratorHash = is_object($options['iterator'])
                ? spl_object_hash($options['iterator'])
                : $options['iterator'];

            $preferredChoiceHashes = $options['preferred_choices'];

            if (is_array($preferredChoiceHashes)) {
                array_walk_recursive($preferredChoiceHashes, function (&$value) {
                    $value = spl_object_hash($value);
                });
            }

            // Support for closures
            $groupByHash = is_object($options['group_by'])
                ? spl_object_hash($options['group_by'])
                : $options['group_by'];

            $hash = md5(json_encode(array(
                spl_object_hash($entityManager),
                $options['model_class_name'],
                $options['selector_class_name'],
                $propertyHash,
                $preferredChoiceHashes,
                $groupByHash,
                $iteratorHash,
            )));

            if (!isset($choiceListCache[$hash])) {
                $choiceListCache[$hash] = new ChoiceLoader(
                    $entityManager,
                    $options['model_class_name'],
                    $options['selector_class_name'],
                    $options['choice_label'],
                    $options['iterator'],
                    $options['preferred_choices'],
                    $options['group_by'],
                    $choiceListFactory
                );
            }

            return $choiceListCache[$hash];
        };

        $resolver->setDefaults(array(
            'em'                => null,
            'query_builder'     => null,
            'choices'           => array(),
            'choice_loader'     => $choiceLoader,
            'group_by'          => null,
            'iterator'          => null,
            'model_class_name'  => null,
            'selector_class_name' => null,
            //'choices_as_values' => true,
        ));

        $resolver->setRequired(array('model_class_name'));

        $resolver->setAllowedTypes('iterator', array('null', 'Yucca\Component\Iterator\Iterator', 'array'));
    }
@param OptionsResolver $resolver

@return mixed