Configure options

@param OptionsResolver $resolver
430538
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setDefaults(
                [
                    'limit_per_page' => 10,
                    'default_sort_column' => 'id',
                    'default_sort_order' => 'asc',
                    'show_actions_column' => true,
                ]
            )
            ->setAllowedTypes('limit_per_page', 'integer')
            ->setAllowedTypes('default_sort_column', 'string')
            ->setAllowedTypes('default_sort_order', 'string')
            ->setAllowedTypes('show_actions_column', 'boolean')
            ->setAllowedValues('default_sort_order', ['asc', 'desc']);
    }
142576
protected function configureIntegerProperty($property, OptionsResolver $resolver)
    {
        $resolver
            ->setAllowedTypes($property, ['integer', 'numeric'])
            ->setNormalizer($property, function (Options $options, $value) {
                return is_int($value) ? $value : intval($value);
            });
    }
1292927
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $defaultConfigs = array(
            'datagrid_exists' => $this->datagridExists,   
        );
        
        $resolver->setDefaults(array(
            'allow_add' => true,
            'allow_delete' => true,
            'prototype' => true,
            'by_reference' => false,
            'type' => 'thrace_multi_select',
            'translation_domain' => 'ThraceFormBundle',
            'configs' => $defaultConfigs,
        ));
        
        $resolver->setNormalizers(array(            
            'configs' => function (Options $options, $value) use ($defaultConfigs){
                $configs = array_replace_recursive($defaultConfigs, $value);
                return $configs;
            }
        ));
          
        $resolver->setRequired(array('grid'));
        
        $resolver->setAllowedTypes(array(
            'grid' => array('object'),
        ));
    }
1280465
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setDefaults(array(
                'required'               => false,
                'data_extraction_method' => 'default',
                'reference_type'         => 'one',
                'reference_name'         => null,
            ))
            ->setRequired(array('reference_type'))
            ->setAllowedValues('data_extraction_method', array('default'))
            ->setAllowedValues('reference_type', array('one', 'many'))
        ;
    }
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;
                }
        ));
    }
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);
    }
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,
        ]);
    }
1119310
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setDefaults([
                'title' => null,
                'class' => Action::class,
                'fields' => [],
                'permissions' => [
                    'ROLE_ADMIN',
                ],
                'export' => [],
                'order' => [],
                'route' => $this->generateRouteName(),
                'route_parameters' => [],
                'route_path' => $this->getDefaultRoutePath(),
                'route_requirements' => [],
                'route_defaults' => [
                    '_controller' => AdminAction::class,
                ],
                'icon' => null,
                'load_strategy' => LAGAdminBundle::LOAD_STRATEGY_NONE,
                'pager' => $this->adminConfiguration->getParameter('pager'),
                'page_parameter' => $this->adminConfiguration->getParameter('page_parameter'),
                'max_per_page' => 30,
                'criteria' => [],
                'filters' => [],
                'menus' => [],
                'template' => $this->getDefaultTemplate(),
                'sortable' => false,
                'string_length' => $this->adminConfiguration->getParameter('string_length'),
                'string_length_truncate' => $this->adminConfiguration->getParameter('string_length_truncate'),
                'date_format' => $this->adminConfiguration->getParameter('date_format'),
                'use_form' => true,
                'form' => null,
            ])
            ->setAllowedTypes('title', [
                'string',
                'null',
            ])
            ->setAllowedTypes('class', 'string')
            ->setAllowedTypes('fields', 'array')
            ->setAllowedTypes('permissions', 'array')
            ->setAllowedTypes('export', 'array')
            ->setAllowedTypes('order', 'array')
            ->setAllowedTypes('route', 'string')
            ->setAllowedTypes('route_parameters', 'array')
            ->setAllowedTypes('route_path', 'string')
            ->setAllowedTypes('route_defaults', 'array')
            ->setAllowedTypes('route_requirements', 'array')
            ->setAllowedTypes('string_length', 'integer')
            ->setAllowedTypes('string_length_truncate', 'string')
            ->setNormalizer('fields', $this->getFieldsNormalizer())
            ->setNormalizer('order', $this->getOrderNormalizer())
            ->setNormalizer('load_strategy', $this->getLoadStrategyNormalizer())
            ->setNormalizer('criteria', $this->getCriteriaNormalizer())
            ->setNormalizer('menus', $this->getMenuNormalizer())
            ->setNormalizer('filters', $this->getFiltersNormalizer())
            ->setNormalizer('route_defaults', $this->getRouteDefaultNormalizer())
            ->setNormalizer('form', $this->getFormNormalizer())
            ->setNormalizer('title', $this->getTitleNormalizer())
            ->setAllowedValues('load_strategy', [
                LAGAdminBundle::LOAD_STRATEGY_NONE,
                LAGAdminBundle::LOAD_STRATEGY_UNIQUE,
                LAGAdminBundle::LOAD_STRATEGY_MULTIPLE,
            ])
            ->setAllowedValues('pager', [
                'pagerfanta',
                false,
                null,
            ])
        ;
    }
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;
            }
        );
    }
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);
            }
        );
    }
137652
private function configureStderrLogProperties(OptionsResolver $resolver)
    {
        $resolver
            ->setDefined('stderr_logfile')
            ->setAllowedTypes('stderr_logfile', 'string');

        $resolver->setDefined('stderr_logfile_maxbytes');
        $this->configureByteProperty('stderr_logfile_maxbytes', $resolver);

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

        $resolver->setDefined('stderr_capture_maxbytes');
        $this->configureByteProperty('stderr_capture_maxbytes', $resolver);

        $resolver->setDefined('stderr_events_enabled');
        $this->configureBooleanProperty('stderr_events_enabled', $resolver);

        $resolver->setDefined('stderr_syslog');
        $this->configureBooleanProperty('stderr_syslog', $resolver);
    }
934192
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'border' => false,
            'sortable' => false,
            'sortable_property' => 'position',
            'prototype' => true,
            'allow_add' => true,
            'by_reference' => false,
            'allow_delete' => true
        ));

        $resolver->setNormalizer('prototype_name', function(Options $options, $value) {
            return '__' . uniqid() . '__';
        });
    }
1200111
public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'data_class' => PayonePaymentTransfer::class,
        ])->setRequired(SubFormInterface::OPTIONS_FIELD_NAME);
    }
927257
protected function configureOptions(OptionsResolver $resolver)
    {
        parent::configureOptions($resolver);
        $resolver->setDefaults(
            [
                'allow_reset' => false,   // Allow the reader to reset it's iterator
                'log_count' => false,   // Log in state history the result count
                'empty_log_level' => LogLevel::WARNING,
            ]
        );
        $resolver->setAllowedValues(
            'empty_log_level',
            [
                LogLevel::ALERT,
                LogLevel::CRITICAL,
                LogLevel::DEBUG,
                LogLevel::EMERGENCY,
                LogLevel::ERROR,
                LogLevel::INFO,
                LogLevel::NOTICE,
                LogLevel::WARNING,
            ]
        );
    }
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);
            }
        );
    }
118218
private function configureProcessProperties(OptionsResolver $resolver)
    {
        $resolver
            ->setRequired('command')
            ->setAllowedTypes('command', 'string');

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

        $resolver->setDefined('numprocs')
            ->setAllowedTypes('numprocs', 'int');

        $resolver->setDefined('numprocs_start')
            ->setAllowedTypes('numprocs_start', 'int');

        $resolver->setDefined('priority')
            ->setAllowedTypes('priority', 'int');
    }
886093
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'auto_init' => true,
                'max_results' => 0,
                'choices' => [],
                'choice_loader' => null,
                'query_uri' => null,
            ]
        );

        $resolver->setNormalizer(
            'query_uri',
            function (Options $options, $value) {
                if (null !== $value) {
                    return $value;
                }
                /** @var AttributeInterface $attribute */
                $attribute = $options['attribute'];
                if (!$attribute) {
                    $allowedFamilies = $options['allowed_families'];
                    if (1 === \count($allowedFamilies)) {
                        try {
                            /** @var FamilyInterface $family */
                            $family = reset($allowedFamilies);

                            return $this->router->generate(
                                'sidus_autocomplete_api_family_search',
                                [
                                    'familyCode' => $family->getCode(),
                                ]
                            );
                        } catch (ExceptionInterface $e) {
                            throw new \RuntimeException('Unable to generate autocomplete route', 0, $e);
                        }
                    }

                    throw new UnexpectedValueException(
                        'Unable to generate API endpoint without an attribute option or a single allowed family'
                    );
                }
                $family = $attribute->getFamily();
                if (!$family) {
                    throw new UnexpectedValueException(
                        'Unable to generate API endpoint without an attribute option with a family'
                    );
                }
                try {
                    return $this->router->generate(
                        'sidus_autocomplete_api_attribute_search',
                        [
                            'attributePath' => $family->getCode().'.'.$attribute->getCode(),
                        ]
                    );
                } catch (ExceptionInterface $e) {
                    throw new \RuntimeException('Unable to generate autocomplete route', 0, $e);
                }
            }
        );
    }