With this method this class can configure an OptionsResolver that will be used to validate the options.

@param OptionsResolver $resolver

@return mixed
777372
public function configureOptionsResolver(OptionsResolver $resolver)
    {
        parent::configureOptionsResolver($resolver);
        $resolver->setDefaults([
            self::OPTION_TTL => $this->defaultTTL,
            self::OPTION_PERSISTENT => $this->defaultPersistence,
            self::OPTION_PRIORITY => 4,
            self::OPTION_EXCHANGE_PATTERN => self::EXCHANGE_PATTERN_IN_ONLY,
            self::OPTION_TRACK => true,
            self::OPTION_PREFIX => '',
        ]);

        $resolver->setRequired([
            self::OPTION_TTL, self::OPTION_PERSISTENT, self::OPTION_PRIORITY, self::OPTION_PREFIX,
            self::OPTION_QUEUE_DRIVER, self::OPTION_QUEUE_NAME,
        ]);

        $resolver->setAllowedTypes(self::OPTION_TTL, ['numeric']);
        $resolver->setAllowedValues(self::OPTION_PERSISTENT, [true, false, 'true', 'false', 0, 1, '0', '1']);
        $resolver->setAllowedTypes(self::OPTION_PERSISTENT, ['numeric', 'string', 'boolean']);
        $resolver->setAllowedTypes(self::OPTION_PRIORITY, ['numeric']);
        $resolver->setAllowedTypes(self::OPTION_PREFIX, ['string']);
        $resolver->setAllowedTypes(self::OPTION_QUEUE_DRIVER, ['string']);
    }
1130566
protected function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'host' => 'localhost',
            'version' => 3,
            'connection_string' => null,
            'encryption' => 'none',
            'options' => [],
        ]);

        $resolver->setDefault('port', function (Options $options) {
            return 'ssl' === $options['encryption'] ? 636 : 389;
        });

        $resolver->setDefault('connection_string', function (Options $options) {
            return sprintf('ldap%s://%s:%s', 'ssl' === $options['encryption'] ? 's' : '', $options['host'], $options['port']);
        });

        $resolver->setAllowedTypes('host', 'string');
        $resolver->setAllowedTypes('port', 'numeric');
        $resolver->setAllowedTypes('connection_string', 'string');
        $resolver->setAllowedTypes('version', 'numeric');
        $resolver->setAllowedValues('encryption', ['none', 'ssl', 'tls']);
        $resolver->setAllowedTypes('options', 'array');
    }
232233
protected function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired(
            [
                'family',
            ]
        );
        /** @noinspection PhpUnusedParameterInspection */
        $resolver->setNormalizer(
            'family',
            function (Options $options, $value) {
                if ($value instanceof FamilyInterface) {
                    return $value;
                }

                return $this->familyRegistry->getFamily($value);
            }
        );
        $resolver->setAllowedTypes('family', ['string', FamilyInterface::class]);
    }
1320177
protected function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired('content');
        $resolver->setAllowedTypes('content', SiteContent::class);

        $resolver->setDefined('exclude_self');
        $resolver->setAllowedTypes('exclude_self', ['bool']);
        $resolver->setDefaults([
            'exclude_self' => true,
        ]);
    }
270566
public function configureOptionsResolver(OptionsResolver $resolver)
    {
        parent::configureOptionsResolver($resolver);
        $resolver->setDefaults([
            self::OPTION_TIMEOUT => 30,
            self::OPTION_CONNECT_TIMEOUT => 30,
            self::OPTION_TRACK => true,
        ]);

        $resolver->setRequired([
            self::OPTION_METHOD, self::OPTION_TIMEOUT, self::OPTION_CONNECT_TIMEOUT,
        ]);

        $resolver->setAllowedTypes(self::OPTION_TIMEOUT, ['numeric']);
        $resolver->setAllowedTypes(self::OPTION_CONNECT_TIMEOUT, ['numeric']);
        $resolver->setAllowedTypes(self::OPTION_METHOD, ['string']);
    }
1129348
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setDefaults([
                // enable or disable extra configuration listener
                'enable_extra_configuration' => true,
                'enable_security' => true,
                'enable_menus' => true,
                'enable_homepage' => true,
                'translation' => false,
                'translation_pattern' => false,
                'title' => 'AdminBundle application',
                'description' => '',
                'locale' => 'en',
                // Main base template as bundles are not loaded when reading the configuration, the kernel
                // locateResources will always failed. So we must not check resource existence here.
                'base_template' => '@LAGAdmin/base.html.twig',
                'block_template' => '@LAGAdmin/Form/fields.html.twig',
                'menu_template' => '@LAGAdmin/Menu/menu.html.twig',
                'list_template' => '@LAGAdmin/CRUD/list.html.twig',
                'edit_template' => '@LAGAdmin/CRUD/edit.html.twig',
                'create_template' => '@LAGAdmin/CRUD/create.html.twig',
                'delete_template' => '@LAGAdmin/CRUD/delete.html.twig',
                'homepage_template' => '@LAGAdmin/Pages/home.html.twig',
                'homepage_route' => 'lag.admin.homepage',
                'routing_url_pattern' => '/{admin}/{action}',
                'routing_name_pattern' => 'lag.admin.{admin}.{action}',
                'bootstrap' => true,
                'date_format' => 'Y/m/d',
                'pager' => 'pagerfanta',
                // string length before truncation (0 means no truncation)
                'string_length' => 200,
                'string_length_truncate' => '...',
                'max_per_page' => 20,
                'admin_class' => Admin::class,
                'action_class' => Action::class,
                'permissions' => 'ROLE_ADMIN',
                'page_parameter' => 'page',
            ])
            ->setAllowedTypes('enable_extra_configuration', 'boolean')
            ->setAllowedTypes('enable_security', 'boolean')
            ->setAllowedTypes('enable_menus', 'boolean')
            ->setAllowedTypes('title', 'string')
            ->setAllowedTypes('description', 'string')
            ->setAllowedTypes('locale', 'string')
            ->setAllowedTypes('base_template', 'string')
            ->setAllowedTypes('block_template', 'string')
            ->setAllowedTypes('bootstrap', 'boolean')
            ->setAllowedTypes('date_format', 'string')
            ->setAllowedTypes('string_length', 'integer')
            ->setAllowedTypes('string_length_truncate', 'string')
            ->setAllowedTypes('max_per_page', 'integer')
            ->setAllowedTypes('admin_class', 'string')
            ->setAllowedTypes('routing_name_pattern', 'string')
            ->setAllowedTypes('routing_url_pattern', 'string')
            ->setAllowedTypes('page_parameter', 'string')
            ->setNormalizer('routing_name_pattern', function(Options $options, $value) {
                if (false === strstr($value, '{admin}')) {
                    throw new InvalidOptionsException(
                        'Admin routing configuration pattern name should contains the {admin} placeholder'
                    );
                }
                if (false === strstr($value, '{action}')) {
                    throw new InvalidOptionsException(
                        'Admin routing configuration pattern name should contains the {action} placeholder'
                    );
                }

                return $value;
            })
            ->setNormalizer('routing_url_pattern', function(Options $options, $value) {
                if (false === strstr($value, '{admin}')) {
                    throw new InvalidOptionsException('Admin routing configuration url pattern should contains {admin} placeholder');
                }

                if (false === strstr($value, '{action}')) {
                    throw new InvalidOptionsException('Admin routing configuration url pattern should contains the {action} placeholder');
                }

                return $value;
            })
        ;
        // admin field type mapping
        $this->setFieldsOptions($resolver);
    }
740476
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        parent::setDefaultOptions($resolver);

        $resolver
            ->setDefaults(array(
                'max_length' => function(Options $options, $previous)
                {
                    if(null !== ($len = $options['field']->getMaxLength()))
                    {
                        return $len;
                    }
                    return $previous;
                }
        ));
    }
1129052
protected function configureEnvironmentProperty(OptionsResolver $resolver)
    {
        $resolver
            ->setDefined('environment')
            ->setAllowedTypes('environment', ['array', 'string'])
            ->setNormalizer('environment', function (Options $options, $value) {
                if (is_array($value)) {
                    $normalized = [];

                    foreach ($value as $key => $val) {
                        is_string($key) and $normalized[] = sprintf('%s="%s"', strtoupper($key), $val);
                    }

                    $value = implode(',', $normalized);
                }

                return $value;
            });
    }
1123978
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
    
        $defaultConfigs = array(
            'showOn' => 'button',
            'buttonImageOnly' => true,
            'timeFormat' => 'HH:mm',
            'showSecond' => false,
        );
    
        $resolver->setDefaults(array(
            'translation_domain' => 'ThraceFormBundle',
            'input' => 'datetime',
            'with_seconds' => false,
            'use_meridiem' => false,
            'date_timezone' => null,
            'user_timezone' => null,
            'time_format' => 'H:i',
            'parts' => array('hour', 'minute'),
            'configs' => $defaultConfigs
        ));
    
        $resolver->setNormalizers(array(
            'time_format' => function (Options $options, $value) {
                if ($options->has('with_seconds') && $options->get('with_seconds') === true){
                    return ($options->get('use_meridiem') === true) ? 'h:i:s a' : 'H:i:s';
                } else {
                    return ($options->get('use_meridiem') === true) ? 'h:i a' : 'H:i';
                } 
            },
            'parts' => function (Options $options, $value){
                if ($options->has('with_seconds') && $options->get('with_seconds') === true){
                    return  array('hour', 'minute', 'second');
                } else {
                    return array('hour', 'minute');
                }
            },
            'configs' => function (Options $options, $value) use ($defaultConfigs) {
                $configs = array_replace_recursive($defaultConfigs, $value);

                if (!$options->has('with_seconds') || $options->get('with_seconds') === false){
                    $configs['timeFormat'] =  ($options->get('use_meridiem') === true) ? 'hh:mm tt' : 'HH:mm';
                    $configs['showSecond'] = false;
                } else {
                    $configs['timeFormat'] =  ($options->get('use_meridiem') === true) ? 'hh:mm:ss tt' : 'HH:mm:ss';
                    $configs['showSecond'] = true;
                }

                return $configs;
            }
        ));
    
        $resolver->setAllowedValues(array(
            'input' => array(
                'datetime',
                'string',
                'timestamp',
                'array',
            ),
            'time_format' => array(
                'H:i:s',
                'h:i:s a',
                'H:i',
                'h:i a'
            ),
        ));
    }
1304206
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'hierarchy' => $this->roleHierarchy->getTreeHierarchy(),
                'required' => false,
            ]
        );
        $resolver->setNormalizer(
            'hierarchy',
            function (Options $options, $value) {
                $error = "'hierarchy' option must be a LeafRole or an array of LeafRole";
                if (!$value instanceof \Traversable && !$value instanceof LeafRole) {
                    throw new \UnexpectedValueException($error);
                }
                if (\is_array($value) || $value instanceof \Traversable) {
                    /** @var array $value */
                    foreach ($value as $item) {
                        if (!$item instanceof LeafRole) {
                            throw new \UnexpectedValueException($error);
                        }
                    }
                }

                return $value;
            }
        );
    }
499397
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $defaultConfigs = $this->options;
    
        $resolver->setDefaults(array(
            'translation_domain' => 'ThraceFormBundle',
            'configs' => $defaultConfigs          
        ));
        
        $resolver->setNormalizers(array(
            'configs' => function (Options $options, $value) use ($defaultConfigs){
                $configs = array_replace_recursive($defaultConfigs, $value);

                return $configs;
            }
        ));
    }
506584
public function configureOptions(OptionsResolver $resolver)
    {
        $that = $this;

        if (!interface_exists(ChoiceLoaderInterface::class)) {
            $resolver->setDefaults([
                'context' => null,
                'category' => null,
                'choice_list' => static function (Options $opts, $previousValue) use ($that) {
                    return new SimpleChoiceList($that->getChoices($opts));
                },
            ]);

            return;
        }
        $resolver->setDefaults([
            'context' => null,
            'category' => null,
            'choice_loader' => static function (Options $opts, $previousValue) use ($that) {
                return new CategoryChoiceLoader(array_flip($that->getChoices($opts)));
            },
        ]);
    }
866625
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'help_label' => null,
            ]
        );
        $resolver->setRequired(
            [
                'attribute',
            ]
        );
        $resolver->setAllowedTypes('attribute', AttributeInterface::class);

        $resolver->setNormalizer(
            'help_label',
            function (Options $options, $value) {
                if (null !== $value) {
                    return $value;
                }
                /** @var AttributeInterface $attribute */
                $attribute = $options['attribute'];

                $messages = [];
                if ($attribute->getType()->isRelation()) {
                    $messages[] = '<p class="text-warning"><b>Warning:</b> This attribute is a relation, in a flat format (like CSV) only the configured column will be exported</p>';
                }
                if ($attribute->isCollection()) {
                    $messages[] = '<p class="text-warning"><b>Warning:</b> This attribute is a collection, in a flat format (like CSV) the values will be joined together using the split character</p>';
                }
                if ($attribute->isUnique()) {
                    return '<p class="text-muted">This attribute is unique</p>';
                }

                return implode("\n", $messages);
            }
        );
    }
1322530
private function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setRequired([
                'username',
                'password',
                'sender',
                'method',
            ])
            ->setDefaults([
                'delivery_start' => null,
                'charset' => Charsets::UTF8,
                'validity_period' => \DateInterval::createFromDateString('2800 minutes'),
                'encoding_schema' => EncodingSchemas::NORMAL,
                'endpoint_uri' => Endpoints::REST_HTTPS,
            ])
            ->setAllowedTypes('username', 'string')
            ->setAllowedTypes('password', 'string')
            ->setAllowedTypes('sender', 'string')
            ->setAllowedTypes('method', 'string')
            ->setAllowedTypes('delivery_start', ['null', 'DateTime'])
            ->setAllowedTypes('validity_period', ['null', 'DateInterval'])
            ->setAllowedTypes('encoding_schema', 'string')
            ->setAllowedTypes('charset', 'string')
            ->setAllowedTypes('endpoint_uri', 'string')
            ->setAllowedValues('method', [
                SendMethods::CLASSIC,
                SendMethods::CLASSIC_PLUS,
                SendMethods::BASIC,
                SendMethods::TEST_CLASSIC,
                SendMethods::TEST_CLASSIC_PLUS,
                SendMethods::TEST_BASIC,
            ])
            ->setAllowedValues('validity_period', function (\DateInterval $value) {
                return $value->i >= ValidityPeriods::MIN && $value->i <= ValidityPeriods::MAX;
            })
            ->setAllowedValues('encoding_schema', [
                EncodingSchemas::NORMAL,
                EncodingSchemas::UCS2,
            ])
            ->setAllowedValues('charset', [
                Charsets::ISO_8859_1,
                Charsets::UTF8,
            ])
        ;
    }
111563
public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setRequired(
            [
                'attribute',
            ]
        );
        $resolver->setAllowedTypes('attribute', ['string', AttributeInterface::class]);
        $resolver->setNormalizer(
            'attribute',
            function (Options $options, $value) {
                /** @var FamilyInterface $family */
                $family = $options['family'];
                if ($value instanceof AttributeInterface) {
                    if (!$family->hasAttribute($value->getCode())) {
                        throw new \UnexpectedValueException(
                            "Family {$family->getCode()} has no attribute named {$value->getCode()}"
                        );
                    }

                    return $value;
                }

                return $family->getAttribute($value);
            }
        );
    }
1354065
protected function configureOptions(OptionsResolver $resolver): void
    {
        // We set object properties' _default_ values to null to ensure we do not create unnecessary objects.
        $resolver->setDefaults([
            static::CONFIG_USER_AGENT_PREFIX => null,
            static::CONFIG_HTTP_CLIENT_BUILDER => null,
            static::CONFIG_JOURNAL => null,
            static::CONFIG_URI_FACTORY => null,
            static::CONFIG_REQUEST_FACTORY => null,
            static::CONFIG_ERROR_FORMATTER => null,
            static::CONFIG_RETRY_PLUGIN_CONFIG => null,
        ]);
        $resolver->setAllowedTypes(static::CONFIG_USER_AGENT_PREFIX, ['null', 'string']);
        $resolver->setAllowedTypes(static::CONFIG_HTTP_CLIENT_BUILDER, ['null', '\Apigee\Edge\HttpClient\Utility\BuilderInterface']);
        $resolver->setAllowedTypes(static::CONFIG_JOURNAL, ['null', '\Apigee\Edge\HttpClient\Utility\JournalInterface']);
        $resolver->setAllowedTypes(static::CONFIG_URI_FACTORY, ['null', '\Http\Message\UriFactory']);
        $resolver->setAllowedTypes(static::CONFIG_REQUEST_FACTORY, ['null', '\Http\Message\RequestFactory']);
        $resolver->setAllowedTypes(static::CONFIG_ERROR_FORMATTER, ['null', '\Http\Message\Formatter']);
        $resolver->setAllowedTypes(static::CONFIG_RETRY_PLUGIN_CONFIG, ['null', 'array']);
    }
691816
protected function callResolver($resolver, $parameters)
    {
        if (is_string($resolver)) {
            return call_user_func_array($resolver, $parameters);
        }

        if (count($parameters) === 0) {
            return $resolver();
        }

        if (count($parameters) === 1) {
            return $resolver($parameters[0]);
        }

        if (count($parameters) === 2) {
            return $resolver($parameters[0], $parameters[1]);
        }

        if (count($parameters) === 3) {
            return $resolver($parameters[0], $parameters[1], $parameters[2]);
        }

        if (count($parameters) === 4) {
            return $resolver($parameters[0], $parameters[1], $parameters[2], $parameters[3]);
        }

        return call_user_func_array($resolver, $parameters);
    }