本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolver::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolver::setDefault方法的具体用法?PHP OptionsResolver::setDefault怎么用?PHP OptionsResolver::setDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolver
的用法示例。
在下文中一共展示了OptionsResolver::setDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureOptions
public function configureOptions(OptionsResolver $resolver)
{
$templates = $this->themeComponent->getTemplates();
$templateChoices = array_combine(array_keys($templates), array_keys($templates));
$resolver->setDefault('choices', $templateChoices);
$resolver->setDefault('empty_data', reset($templates));
}
示例2: configureOptions
/**
* Configure adapter options
*
* @param OptionsResolver $resolver
* @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefined('digest_domains')->setAllowedTypes('digest_domains', 'string');
$resolver->setDefined('nonce_timeout')->setAllowedTypes('nonce_timeout', 'int');
$resolver->setDefault('use_opaque', false)->setAllowedTypes('use_opaque', 'bool');
$resolver->setDefault('algorithm', 'MD5')->setAllowedTypes('algorithm', 'string');
}
示例3: configureOptions
/**
*
* {@inheritdoc}
*
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array('compound' => false, 'metadata' => null, 'icon' => 'fa fa-key', 'class' => null));
$resolver->setDefault('prefixText', null);
$resolver->setDefault('suffixIcon', null);
$resolver->setDefault('suffixText', null);
}
示例4: __construct
/**
* Constructor.
*
* @param array|null $options
*/
public function __construct(array $options = array())
{
$resolver = new OptionsResolver();
$resolver->setRequired(['type', 'match']);
$resolver->setDefault('type', function (Options $options, $value) {
if (null === $value) {
return;
}
});
$resolver->setDefault('match', function (Options $options, $value) {
if (null === $value) {
return;
}
});
$resolver->setAllowedValues('type', function ($value) {
if (in_array($value, ['json', 'xml', 'html'])) {
return true;
}
if (null == $value) {
return true;
}
});
$resolver->setAllowedTypes('type', ['string', 'null']);
$options = $resolver->resolve($options);
$this->type = $options['type'];
$this->match = $options['match'];
}
示例5: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefault('connection', null)->setAllowedTypes('connection', ['string', 'null']);
// To be removed when bumping symfony/form constraint to version 3.1+
if (!in_array(DataTransformerInterface::class, class_implements(TextType::class))) {
$resolver->setDefault('choices_as_values', true);
}
}
示例6: configureOptions
protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefault('local_assets_dir', null);
$resolver->setDefault('remote_assets_dir', '%remote_webapp_dir%');
$resolver->setDefault('tags', []);
$resolver->setRequired(['project_name', 'git_repository_url', 'git_target_branch', 'local_git_repository_dir', 'remote_git_repository_dir', 'local_webapp_dir', 'local_vendor_dir', 'remote_webapp_dir', 'remote_vendor_dir', 'remote_phpunit_configuration_xml_path', 'remote_symfony_console_path']);
$resolver->setAllowedTypes('tags', 'array');
}
示例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: resolveOptions
/**
* Get required options for the Billingo API to work
* @param $opts
* @return mixed
*/
protected function resolveOptions($opts)
{
$resolver = new OptionsResolver();
$resolver->setDefault('version', '2');
$resolver->setDefault('host', 'https://www.billingo.hu/api/');
// might be overridden in the future
$resolver->setDefault('leeway', 60);
$resolver->setRequired(['host', 'private_key', 'public_key', 'version', 'leeway']);
return $resolver->resolve($opts);
}
示例9: configureOptions
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefault('widget', 'compact');
$resolver->setAllowedValues('widget', ['browser', 'compact']);
$resolver->setDefault('root_node', '/');
$resolver->setAllowedValues('root_node', function ($value) {
return '/' === $value[0];
});
$resolver->setDefault('repository_name', 'default');
}
示例10: configureOptions
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(['label' => null, 'label_attr' => [], 'header_attr' => [], 'cell_attr' => [], 'label_translation_domain' => null, 'block_name' => null]);
$resolver->setDefault('parent_column', null);
$resolver->setDefault('data_provider', null);
$resolver->setAllowedTypes('label', ['string', 'null']);
$resolver->setAllowedTypes('label_attr', 'array');
$resolver->setAllowedTypes('header_attr', 'array');
$resolver->setAllowedTypes('cell_attr', 'array');
$resolver->setAllowedTypes('data_provider', ['Closure', 'null', 'string', PropertyPath::class]);
}
示例11: getGeocode
/**
* The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request.
* The request specifies a textual search string and optional geographic bounds. The service can be used to provide
* autocomplete functionality for text-based geographic searches, by returning places such as businesses, addresses
* and points of interest as a user types.
*
* @param array $parameters
* @see https://developers.google.com/places/web-service/autocomplete
* @return GeocodeResult
*/
public function getGeocode(array $parameters)
{
// Required and optional parameters for this function call
$options = new OptionsResolver();
$options->setDefault('output', 'json');
$options->setDefault('language', 'en');
$options->setDefined(['latlng', 'place_id']);
$options = $options->resolve($parameters);
// Place the call
$uri = $this->buildUri(sprintf('%s/%s', static::GEOCODE_BASE_URL, $options['output']), $this->options['key'], $parameters);
$request = $this->client->request('GET', $uri);
return new GeocodeResult($request, $options['language']);
}
示例12: 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);
}
示例13: getPlaceDetails
/**
* Once you have a place_id or a reference from a Place Search, you can request more details about a particular
* establishment or point of interest by initiating a Place Details request. A Place Details request returns more
* comprehensive information about the indicated place such as its complete address, phone number, user
* rating and reviews.
* @param array $parameters
* @see https://developers.google.com/places/web-service/details
* @return PlaceResult
*/
public function getPlaceDetails(array $parameters)
{
// Required and optional parameters for this function call
$options = new OptionsResolver();
$options->setDefault('output', 'json');
$options->setDefault('language', 'en');
$options->setRequired(['placeid']);
$options->setDefined(['extensions', 'language']);
$options = $options->resolve($parameters);
// Place the call
$uri = $this->buildUri(sprintf('%s/%s', static::PLACE_DETAILS_BASE_URL, $options['output']), $this->options['key'], $parameters);
$request = $this->client->request('GET', $uri);
return new PlaceResult($request, $options['language']);
}
示例14: configureOptions
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
// This is a child of the choice type so its possible to change the the choice list data. This
// is something that is not wanted since this a choice type specifically made to list the current
// channels. So the choice_loader is force to a ChannelChoiceLoader no mather the options that
// are supplied.
$choiceLoaderNormalizer = function (Options $options) {
return new ChannelChoiceLoader($this->repository, $this->factory);
};
$resolver->setNormalizer('choice_loader', $choiceLoaderNormalizer);
$resolver->setDefault('choice_data', 'object');
$resolver->setDefault('choice_value', 'id');
$resolver->setDefault('choice_label', 'name');
$resolver->setAllowedValues('choice_data', ['object', 'scalar']);
}
示例15: __construct
/**
* LDAP constructor.
* @param array $options
*/
public function __construct(array $options)
{
$resolver = new OptionsResolver();
$resolver->setDefault('anonymous', false);
$resolver->setRequired(array('host', 'domain', 'username', 'password', 'base_dn'));
$this->options = $resolver->resolve($options);
}