本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolver::setRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolver::setRequired方法的具体用法?PHP OptionsResolver::setRequired怎么用?PHP OptionsResolver::setRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolver
的用法示例。
在下文中一共展示了OptionsResolver::setRequired方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param string $themeClassName
* @param PropertyAccessorInterface $propertyAccessor
*/
public function __construct($themeClassName, PropertyAccessorInterface $propertyAccessor)
{
$this->themeClassName = $themeClassName;
$this->propertyAccessor = $propertyAccessor;
$this->optionsResolver = new OptionsResolver();
$this->optionsResolver->setRequired(['name', 'slug'])->setDefined('description')->setDefault('parents', [])->setAllowedTypes('parents', 'array');
}
示例2: configureWeekMealOptions
/**
* Set up the configurations of options
* passed as argument into the following methods of this class :
* - getWeekDates
* - getWeekMeals
*/
private function configureWeekMealOptions()
{
$this->weekMealResolver->setDefined(array('date_day', 'without_pork', 'enable_next_week', 'days_ofweek_off', 'dates_off'));
$this->weekMealResolver->setAllowedTypes('date_day', \DateTimeInterface::class);
$this->weekMealResolver->setDefaults(array('without_pork' => false, 'enable_next_week' => false, 'days_ofweek_off' => array(Day::WEEK_WEDNESDAY), 'dates_off' => array()));
$this->weekMealResolver->setRequired(array('without_pork', 'date_day'));
}
示例3: __construct
/**
* ActivityRepositoryAbstract constructor.
*
* @inheritdoc
*/
public function __construct($em, \Doctrine\ORM\Mapping\ClassMetadata $class)
{
$this->dayListResolver = new OptionsResolver();
$this->dayListResolver->setRequired(array('date_day', 'school'));
$this->configureDayListOptions($this->dayListResolver);
parent::__construct($em, $class);
}
示例4: configureOptions
protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired("type");
$resolver->setRequired("name");
$resolver->setAllowedValues('type', ['url', 'image', 'text', 'page_select', 'product_category_select', 'product_select', 'collection_select']);
$resolver->setDefaults(array('type' => 'text', 'options' => 'options'));
}
示例5: configureOptions
/**
* Configure adapter options
*
* @param OptionsResolver $resolver
* @throws \Symfony\Component\OptionsResolver\Exception\AccessException
* @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('username')->setAllowedTypes('username', ['string']);
$resolver->setRequired('password')->setAllowedTypes('password', ['string']);
$resolver->setRequired('roles')->setAllowedTypes('roles', ['array']);
$resolver->setDefined('salt')->setAllowedTypes('salt', ['string', 'null']);
}
示例6: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired(array('relative_path'));
$resolver->setRequired(array('imagine_filter'));
$resolver->setDefaults(array('class' => '', 'padding' => '', 'name' => '', 'orderable' => false, 'searchable' => false, 'title' => '', 'type' => '', 'visible' => true, 'width' => '', 'search_type' => 'like', 'filter_type' => 'text', 'filter_options' => array(), 'filter_property' => '', 'filter_search_column' => '', 'holder_url' => '', 'holder_width' => '50', 'holder_height' => '50', 'enlarge' => false));
$resolver->setAllowedTypes('class', 'string');
$resolver->setAllowedTypes('padding', 'string');
$resolver->setAllowedTypes('name', 'string');
$resolver->setAllowedTypes('orderable', 'bool');
$resolver->setAllowedTypes('searchable', 'bool');
$resolver->setAllowedTypes('title', 'string');
$resolver->setAllowedTypes('type', 'string');
$resolver->setAllowedTypes('visible', 'bool');
$resolver->setAllowedTypes('width', 'string');
$resolver->setAllowedTypes('search_type', 'string');
$resolver->setAllowedTypes('filter_type', 'string');
$resolver->setAllowedTypes('filter_options', 'array');
$resolver->setAllowedTypes('filter_property', 'string');
$resolver->setAllowedTypes('filter_search_column', 'string');
$resolver->setAllowedTypes('imagine_filter', 'string');
$resolver->setAllowedTypes('relative_path', 'string');
$resolver->setAllowedTypes('holder_url', 'string');
$resolver->setAllowedTypes('holder_width', 'string');
$resolver->setAllowedTypes('holder_height', 'string');
$resolver->setAllowedTypes('enlarge', 'bool');
$resolver->setAllowedValues('search_type', array('like', 'notLike', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'in', 'notIn', 'isNull', 'isNotNull'));
$resolver->setAllowedValues('filter_type', array('text', 'select'));
return $this;
}
示例7: __construct
public function __construct(TokenRetrieveHelper $helper, array $config = [])
{
$this->config = $config;
$this->helper = $helper;
$this->optionsResolver = new OptionsResolver();
$this->optionsResolver->setRequired(['client_id', 'client_secret', 'grant_type']);
$this->optionsResolver->setDefault('grant_type', $this->getGrantType());
}
示例8: __construct
/**
* Instanciate the base filter
*
* @param AttributeValidatorHelper $attrValidatorHelper
* @param ConfigurationRegistryInterface $registry
* @param ReferenceDataIdResolver $idsResolver
* @param array $supportedOperators
*/
public function __construct(AttributeValidatorHelper $attrValidatorHelper, ConfigurationRegistryInterface $registry, ReferenceDataIdResolver $idsResolver, array $supportedOperators = [])
{
$this->attrValidatorHelper = $attrValidatorHelper;
$this->registry = $registry;
$this->idsResolver = $idsResolver;
$this->supportedOperators = $supportedOperators;
$this->optionsResolver = new OptionsResolver();
$this->optionsResolver->setRequired(['field'])->setDefined(['locale', 'scope']);
}
示例9: configureOptions
/**
* Configure adapter options
*
* @param OptionsResolver $resolver
* @throws \Symfony\Component\OptionsResolver\Exception\AccessException
* @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('table_name')->setAllowedTypes('table_name', ['string']);
$resolver->setRequired('identity_column')->setAllowedTypes('identity_column', ['string']);
$resolver->setRequired('credential_column')->setAllowedTypes('credential_column', ['string']);
$resolver->setDefined('roles_column')->setAllowedTypes('roles_column', ['string', 'null']);
$resolver->setDefined('salt_column')->setAllowedTypes('salt_column', ['string', 'null']);
$resolver->setDefault('use_ambiguity_identity', false)->setAllowedTypes('use_ambiguity_identity', ['bool']);
}
示例10: __construct
/**
* @param array $params
* @param ApplicationPaths $appPaths
* @param ActiveTheme $theme
* @param RequestStack $requestStack
* @param string $env
*/
public function __construct(array $params, ApplicationPaths $appPaths, ActiveTheme $theme, RequestStack $requestStack, $env)
{
$this->params = $params;
$this->appPaths = $appPaths;
$this->theme = $theme;
$this->request = $requestStack;
$this->env = $env;
$this->resolver = new OptionsResolver();
$this->resolver->setRequired('resources');
$this->resolver->setRequired('translations');
$this->resolver->setAllowedTypes('resources', ['array']);
$this->resolver->setAllowedTypes('translations', ['array']);
}
示例11: configurePayload
/**
* @inheritdoc
*/
public function configurePayload(OptionsResolver $resolver)
{
$resolver->setRequired(0);
$resolver->setAllowedTypes(0, 'numeric');
$resolver->setNormalizer(0, function (Options $options, $value) {
if (null === ($scraper = $this->findScraper($value))) {
throw new InvalidArgumentException(sprintf('Could not find scraper with id %d', $value));
}
return $scraper;
});
$resolver->setRequired(1);
$resolver->setAllowedTypes(1, 'string');
}
示例12: __construct
public function __construct()
{
$this->allowedTypes = array_merge(array('driver' => array('string'), 'options' => array('array', 'null'), 'attributes' => array('array')), $this->allowedTypes);
$this->allowedValues = array_merge(array('driver' => array($this->driver)), $this->allowedValues);
$this->defaults = array_merge(array('driver' => $this->driver, 'options' => array(), 'attributes' => array()), $this->defaults);
$this->resolver = new OptionsResolver();
$this->resolver->setRequired($this->required)->setDefaults($this->defaults);
foreach ($this->allowedValues as $option => $value) {
$this->resolver->setAllowedValues($option, $value);
}
foreach ($this->allowedTypes as $option => $value) {
$this->resolver->setAllowedTypes($option, $value);
}
}
示例13: setOptions
/**
* @param array $options
*/
public function setOptions($options = array())
{
$resolver = new OptionsResolver();
$resolver->setDefaults(array());
$resolver->setRequired('slider_id');
$resolver->setAllowedTypes('slider_id', 'string');
$resolver->setRequired('start');
$resolver->setAllowedTypes('start', 'array');
$resolver->setRequired('range_min');
$resolver->setAllowedTypes('range_min', 'numeric');
$resolver->setRequired('range_max');
$resolver->setAllowedTypes('range_max', 'numeric');
$resolver->setDefined('range_steps');
$resolver->setAllowedTypes('range_steps', 'array');
$resolver->setDefined('step');
$resolver->setAllowedTypes('step', 'numeric');
$resolver->setDefined('connect');
$resolver->setAllowedTypes('connect', 'string');
$resolver->setAllowedValues('connect', array('lower', 'upper', 'true', 'false'));
$resolver->setDefault('connect', 'false');
$resolver->setDefined('margin');
$resolver->setAllowedTypes('margin', 'numeric');
$resolver->setDefined('limit');
$resolver->setAllowedTypes('margin', 'numeric');
$resolver->setDefined('orientation');
$resolver->setAllowedTypes('orientation', 'string');
$resolver->setAllowedValues('orientation', array('vertical', 'horizontal'));
$resolver->setDefault('orientation', 'horizontal');
$resolver->setDefined('slider_dimension');
$resolver->setAllowedTypes('slider_dimension', 'array');
$resolver->setDefined('direction');
$resolver->setAllowedTypes('direction', 'string');
$resolver->setAllowedValues('direction', array('ltr', 'rtl'));
$resolver->setDefault('direction', 'ltr');
$resolver->setDefined('animate');
$resolver->setAllowedTypes('animate', 'boolean');
$resolver->setDefault('animate', true);
$resolver->setDefined('animation_duration');
$resolver->setAllowedTypes('animation_duration', 'numeric');
$resolver->setDefined('tooltips');
$resolver->setAllowedTypes('tooltips', 'array');
//events
$resolver->setDefined('update_event');
$resolver->setDefined('change_event');
$resolver->setDefined('set_event');
$resolver->setDefined('slide_event');
$resolver->setDefined('start_event');
$resolver->setDefined('end_event');
$this->options = $resolver->resolve($options);
}
示例14: configurePayload
/**
* @inheritdoc
*/
public function configurePayload(OptionsResolver $resolver)
{
$resolver->setRequired(0);
$resolver->setRequired(1);
$resolver->setAllowedTypes(0, 'string');
$resolver->setAllowedTypes(1, 'array');
$resolver->setNormalizer(1, function (Options $options, $value) {
$class = $options[0];
if (null === ($item = $this->doctrine->getRepository($class)->findOneBy($value))) {
throw new InvalidArgumentException(sprintf('Could not find %s with id %d', $class, $value));
}
return $item;
});
}
示例15: configureOptions
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefined(['customFormModel', 'territoryRepository', 'projectSettings']);
$resolver->setRequired(['customFormModel', 'territoryRepository', 'projectSettings']);
$resolver->addAllowedTypes('customFormModel', CustomFormModelInterface::class);
$resolver->addAllowedTypes('projectSettings', ProjectSettings::class);
}