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

@param OptionsResolver $resolver

@return mixed
546379
public function configureOptionsResolver(OptionsResolver $resolver)
    {
        parent::configureOptionsResolver($resolver);

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

        $resolver->setAllowedTypes(self::OPTION_SERVICE, ['string']);
        $resolver->setAllowedTypes(self::OPTION_METHOD, ['string']);
    }
1074065
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'choices' => null,
                'families' => null,
            ]
        );

        $resolver->setNormalizer(
            'families',
            function (Options $options, $values) {
                if (null === $values) {
                    $values = $this->familyRegistry->getFamilies();
                }
                $families = [];
                foreach ($values as $value) {
                    if (!$value instanceof FamilyInterface) {
                        $value = $this->familyRegistry->getFamily($value);
                    }
                    if ($value->isInstantiable()) {
                        $families[$value->getCode()] = $value;
                    }
                }

                return $families;
            }
        );
        $resolver->setNormalizer(
            'choices',
            function (Options $options, $value) {
                if (null !== $value) {
                    throw new \UnexpectedValueException(
                        "'choices' options is not supported for family selector, please use 'families' option"
                    );
                }
                $choices = [];
                /** @var FamilyInterface[] $families */
                $families = $options['families'];
                $duplicates = [];
                foreach ($families as $family) {
                    if ($family->isInstantiable()) {
                        $label = ucfirst($family);
                        if (array_key_exists($label, $choices)) {
                            // Storing duplicates
                            $duplicates[] = $label;
                            $label = "{$label} ({$family->getCode()})";
                        }
                        $choices[$label] = $family->getCode();
                    }
                }

                // Recreating duplicates
                foreach ($duplicates as $duplicate) {
                    $choices["{$duplicate} ({$choices[$duplicate]})"] = $choices[$duplicate];
                    unset($choices[$duplicate]);
                }
                ksort($choices);

                return $choices;
            }
        );
    }
938334
public function configureOptions(OptionsResolver $resolver)
    {
        // user can defined an admin name
        $resolver
            ->setDefault('admin', null)
            ->setDefault('action', null)
            ->setDefault('route', null)
            ->setDefault('url', null)
            ->setDefault('parameters', [])
            ->setDefault('text', '')
            ->setDefault('attr', [])
            ->setDefault('link_attr', [
                'class' => 'nav-link',
            ])
            ->setDefault('items', [])
            ->setDefault('icon', null)
            ->setDefault('link_css_class', 'nav-link')
            ->setNormalizer('admin', function(Options $options, $adminName) {
                // user has to defined either an admin name and an action name, or a route name with optional
                // parameters, or an url
                if (null === $adminName
                    && null === $options->offsetGet('route')
                    && null === $options->offsetGet('url')
                ) {
                    throw new InvalidOptionsException(
                        'You should either defined an admin name, or route name or an uri'
                    );
                }

                return $adminName;
            })
            // if an admin name is set, an action name can provided. This action will be the menu link
            ->setNormalizer('action', function(Options $options, $action) {
                // if an action name is provided, an admin name should be defined too
                if (null !== $action && null === $options->offsetGet('admin')) {
                    throw new InvalidOptionsException(
                        'You should provide an admin name for this action '.$action
                    );
                }

                // default to list action
                if (null !== $options->offsetGet('admin') && null === $action) {
                    $action = 'list';
                }

                return $action;
            })
            ->setAllowedTypes('parameters', 'array')
            ->setNormalizer('attr', function(Options $options, $attr) {
                if (!is_array($attr)) {
                    $attr = [];
                }

                if (empty($attr['id'])) {
                    $attr['id'] = uniqid('admin-menu-');
                }

                if ('horizontal' === $this->position && !key_exists('class', $attr)) {
                    $attr['class'] = 'nav-item';
                }

                return $attr;
            })
            ->setNormalizer('link_attr', function(Options $options, $value) {
                if (!is_array($value)) {
                    $value = [];
                }

                if (!key_exists('class', $value)) {
                    $value['class'] = 'nav-link';
                }

                return $value;
            })
            ->setNormalizer('items', function(Options $options, $items) {
                if (!is_array($items)) {
                    $items = [];
                }
                $resolver = new OptionsResolver();
                $resolvedItems = [];

                foreach ($items as $name => $item) {
                    $itemConfiguration = new MenuItemConfiguration($name, $this->position);
                    $itemConfiguration->configureOptions($resolver);
                    $itemConfiguration->setParameters($resolver->resolve($item));

                    $resolvedItems[$name] = $itemConfiguration;
                }

                return $resolvedItems;
            })
            ->setNormalizer('text', function(Options $options, $text) {
                if (!$text) {
                    // TODO use translation pattern key instead
                    $text = ucfirst($this->name);
                }

                return $text;
            })
        ;
    }
1282325
private function configureLogProperties(OptionsResolver $resolver)
    {
        $resolver->setDefined('redirect_stderr');
        $this->configureBooleanProperty('redirect_stderr', $resolver);

        $this->configureStdoutLogProperties($resolver);
        $this->configureStderrLogProperties($resolver);
    }
929791
public function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefaults(
            [
                'attribute' => null,
                'create_missing' => true,
            ]
        );
        $resolver->setAllowedTypes('attribute', ['NULL', 'string', AttributeInterface::class]);
        $resolver->setAllowedTypes('create_missing', ['bool']);
        $resolver->setNormalizer(
            'attribute',
            function (Options $options, $value) {
                /** @var FamilyInterface $family */
                $family = $options['family'];

                if (null !== $value) {
                    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);
                }

                if (!array_key_exists($family->getCode(), $this->familyMap)) {
                    throw new \UnexpectedValueException(
                        'Unknown asset family detected, please specify the attribute for resource storage'
                    );
                }

                return $this->familyMap[$family->getCode()];
            }
        );
    }
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;
            }
        );
    }
759249
protected function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired(array());

        $resolver->setDefaults(array(
            'id' => null,
            'css' => null,
            'charset' => 'UTF-8',
            'domain' => $title = $this->getSetting('domain'),
            'title' => $title = $this->getSetting('title'),
            'locale' => $this->getSetting('locale'),
            'metas' => array(
                'keywords' => $keywords = $this->getSetting('meta_keywords'),
                'description' => $description = $this->getSetting('meta_description'),
                'robots' => $this->getSetting('meta_robots'),
            ),
            'blocks' => null,
            'styles' => null,
            'scripts' => null,
            'keywords' => $keywords,
            'description' => $description,
            'breadcrumbs' => null,
            'reset_script' => false,
            'reset_style' => false,
            'reset_meta' => false,
            'reset_breadcrumb' => false,
            'heading' => null,
            'icon' => null,
            'canonical' => null,
            'inited' => false,
            'extras' => array(),
        ));

        $resolver->setAllowedTypes(array(
            'inited' => array('boolean'),
            'heading' => array('null', 'string'),
            'icon' => array('null', 'string'),
            'metas' => array('null', 'array'),
            'blocks' => array('null', 'array'),
            'extras' => array('null', 'array'),
        ));
    }
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']);
    }
416607
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired(
            [
                'admin_action',
            ]
        );
        $resolver->setAllowedTypes('admin_action', ['string', Action::class]);
        $resolver->setDefaults(
            [
                'admin' => null,
            ]
        );
        $resolver->setAllowedTypes('admin', ['NULL', 'string', Admin::class]);
        $resolver->setNormalizer(
            'admin',
            function (Options $options, $value) {
                if ($value instanceof Admin) {
                    return $value;
                }
                if (null === $value) {
                    return $this->adminRegistry->getCurrentAdmin();
                }

                return $this->adminRegistry->getAdmin($value);
            }
        );
        $resolver->setNormalizer(
            'admin_action',
            function (Options $options, $value) {
                /** @var Admin $admin */
                $admin = $options['admin'];

                if ($value instanceof Action) {
                    if ($value->getAdmin() !== $admin) {
                        throw new \LogicException(
                            "Wrong Admin for Action {$value->getCode()}: {$value->getAdmin()->getCode()}"
                        );
                    }

                    return $value;
                }

                return $admin->getAction($value);
            }
        );
        $resolver->setNormalizer(
            'uri',
            function (Options $options, $value) {
                if (null === $value) {
                    return $this->adminRouter->generateAdminPath(
                        $options['admin'],
                        $options['admin_action']->getCode(),
                        $options['route_parameters']
                    );
                }

                return $value;
            }
        );
    }
184417
private function configureProcessProperties(OptionsResolver $resolver)
    {
        $resolver
            ->setRequired('command')
            ->setAllowedTypes('command', 'string');

        $resolver
            ->setDefined('process_name')
            ->setAllowedTypes('process_name', 'string');

        $resolver->setDefined('numprocs');
        $this->configureIntegerProperty('numprocs', $resolver);

        $resolver->setDefined('numprocs_start');
        $this->configureIntegerProperty('numprocs_start', $resolver);

        $resolver->setDefined('priority');
        $this->configureIntegerProperty('priority', $resolver);
    }
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);
            }
        );
    }
455724
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        
        $defaultConfigs = array(
            'width' => '300px',
            'allowClear' => true,  
        );
        
        $defaults = array(
            'multiple' => false,
            'expanded' => false,
            'empty_value' => 'select.empty_value',
            'translation_domain' => 'ThraceFormBundle',
            'configs' => $defaultConfigs
        );
        
        $normalizers = array(
            'expanded' => function (Options $options, $value) {
                return false;
            },           
            'configs' => function (Options $options, $value) use ($defaultConfigs) {
                $configs = array_replace_recursive($defaultConfigs, $value);
                
                $configs['placeholder'] = $options->get('empty_value');
                
                if(true === $options->get('multiple') && isset($configs['ajax'])){
                    $configs['multiple'] = true;
                }

                return $configs;
            }
        );
         
        $resolver->setDefaults($defaults);
        
        $resolver->setNormalizers($normalizers);
    }
70741
public function configureOptionsResolver(OptionsResolver $resolver)
    {
        parent::configureOptionsResolver($resolver);
        $resolver->setDefaults([
            self::OPTION_DELIMITER => ',',
            self::OPTION_ENCLOSURE => '"',
            self::OPTION_ESCAPE_CHAR => '\\',
            self::OPTION_MAX_LENGTH => 1000,
            self::OPTION_STOP_ON_EOF => false,
        ]);

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

        $resolver->setAllowedTypes(self::OPTION_PATH, ['string']);
        $resolver->setAllowedTypes(self::OPTION_DELIMITER, ['string']);
        $resolver->setAllowedTypes(self::OPTION_ENCLOSURE, ['string']);
        $resolver->setAllowedTypes(self::OPTION_ESCAPE_CHAR, ['string']);
        $resolver->setAllowedTypes(self::OPTION_METHOD, ['string']);
        $resolver->setAllowedTypes(self::OPTION_STOP_ON_EOF, ['bool']);
    }
793420
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        
        $defaultConfigs = array(
            'showOn' => 'button',
            'buttonImageOnly' => true,
        );
        
        $resolver->setDefaults(array(
            'input' => 'datetime',
            'format' => 'Y-m-d',
            'date_timezone' => null,
            'user_timezone' => null,
            'translation_domain' => 'ThraceFormBundle',
            'configs' => $defaultConfigs,
    
        ));
        
        $resolver->setNormalizers(array(
            'format' => function (Options $options, $value) {
                return 'Y-m-d';
            },
            'configs' => function (Options $options, $value) use ($defaultConfigs) {
                $configs = array_replace_recursive($defaultConfigs, $value);
                
                $configs['dateFormat'] = 'yy-mm-dd';
                
                return $configs;
            }
        ));

        $resolver->setAllowedValues(array(
            'input' => array(
                'datetime',
                'string',
                'timestamp',
                'array',
            )   
        ));
    }
1295746
private function getOptionsResolver()
    {
        if (!$this->optionsResolver) {
            $this->optionsResolver = new OptionsResolver();
            $this->configureResolver($this->optionsResolver);
        }

        return $this->optionsResolver;
    }
821891
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {      
        $defaultConfigs = array(
            'tpl' => 'slider.value: __value__',
            'min' => 0,
            'max' => 100,
            'orientation' => 'horizontal',
            'width' => '300px',
            'height' => '300px',
            'range' => 'min',
       );
        
        $resolver->setDefaults(array(
            'translation_domain' => 'NeutronFormBundle',
            'configs' => $defaultConfigs,
        ));
        
        $resolver->setNormalizers(array(
            'configs' => function (Options $options, $value) use ($defaultConfigs) {
                $value = array_replace_recursive($defaultConfigs, $value);
                
                if($value['orientation'] == 'horizontal'){
                    unset($value['height']);
                } else {
                    unset($value['width']);
                }
                
                if (!in_array($value['range'], array('min', 'max'), true)){
                    throw new \InvalidArgumentException(sprintf('Option range with value "%s" must be set to  "min" or "max"', $value['range']));
                }
                
                return $value;
            }
        ));
    }
591535
public function configureOptionsResolver(OptionsResolver $resolver)
    {
        parent::configureOptionsResolver($resolver);
        $resolver->setRequired([
            self::OPTION_NOSQL_DRIVER,
            self::OPTION_COLLECTION_PREFIX,
            self::OPTION_COLLECTION_NAME,
            self::OPTION_METHOD
        ]);

        $resolver->setAllowedTypes(self::OPTION_COLLECTION_NAME, ['string']);
        $resolver->setAllowedTypes(self::OPTION_COLLECTION_PREFIX, ['string']);
        $resolver->setAllowedTypes(self::OPTION_NOSQL_DRIVER, ['string']);
        $resolver->setAllowedTypes(self::OPTION_METHOD, ['string']);
    }