Form/Type/LdapObjectType.php
public function configureOptions(OptionsResolver $resolver)
    {
        $ldap = $this->ldap;

        $resolver->setDefaults([
            'ldap_domain' => $this->ldap->getDomainContext(), // The LDAP domain context
            'ldap_attributes' => null, // The attributes to select
            'ldap_query_builder' => null, // A closure or a LdapQueryBuilder instance
            'choice_name' => 'name',
            'choice_value' => 'guid',
            'choices' => [], // A user supplied array of LDAP objects.
            'choice_loader' => function (Options $options) use ($ldap) {
                if (!interface_exists('\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')) {
                    return null;
                }

                return new LdapObjectChoiceLoader($ldap,
                    $options['ldap_type'],
                    $options['choice_name'],
                    $options['choice_value'],
                    $options['ldap_query_builder']
                );
            },
            'choice_list' => function (Options $options) use ($ldap) {
                // Always prefer the ChoiceLoader if it exists. Fall back to the ObjectChoiceList...
                if (interface_exists('\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')) {
                    return null;
                }
                $legacyChoiceLoader = new LegacyLdapChoiceLoader($ldap, $options['ldap_type'], $options['choice_name'], $options['choice_value'], $options['ldap_query_builder']);
                $preferred = isset($options['preferred_choices']) ? $options['preferred_choices'] : [];

                return new LdapObjectChoiceList(
                    $legacyChoiceLoader->load(),
                    $options['choice_name'],
                    $preferred,
                    null,
                    $options['choice_value']
                );
            },
        ]);
        $resolver->setRequired(['ldap_type']);
        $this->setAllowedTypes($resolver);
    }
public function configureOptions(OptionsResolver $resolver)
    {
        $ldap = $this->ldap;

        $resolver->setDefaults([
            'ldap_domain' => $this->ldap->getDomainContext(), // The LDAP domain context
            'ldap_attributes' => null, // The attributes to select
            'ldap_query_builder' => null, // A closure or a LdapQueryBuilder instance
            'choice_name' => 'name',
            'choice_value' => 'guid',
            'choices' => [], // A user supplied array of LDAP objects.
            'choice_loader' => function (Options $options) use ($ldap) {
                if (!interface_exists('\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')) {
                    return null;
                }

                return new LdapObjectChoiceLoader($ldap,
                    $options['ldap_type'],
                    $options['choice_name'],
                    $options['choice_value'],
                    $options['ldap_query_builder']
                );
            },
            'choice_list' => function (Options $options) use ($ldap) {
                // Always prefer the ChoiceLoader if it exists. Fall back to the ObjectChoiceList...
                if (interface_exists('\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')) {
                    return null;
                }
                $legacyChoiceLoader = new LegacyLdapChoiceLoader($ldap, $options['ldap_type'], $options['choice_name'], $options['choice_value'], $options['ldap_query_builder']);
                $preferred = isset($options['preferred_choices']) ? $options['preferred_choices'] : [];

                return new LdapObjectChoiceList(
                    $legacyChoiceLoader->load(),
                    $options['choice_name'],
                    $preferred,
                    null,
                    $options['choice_value']
                );
            },
        ]);
        $resolver->setRequired(['ldap_type']);
        $this->setAllowedTypes($resolver);
    }
{@inheritdoc}