當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OptionsResolver::setDefault方法代碼示例

本文整理匯總了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));
 }
開發者ID:cmsilex,項目名稱:cmsilex,代碼行數:7,代碼來源:TemplateChoiceType.php

示例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');
 }
開發者ID:sunnyct,項目名稱:silexcmf-zend-authentication,代碼行數:13,代碼來源:HttpDigest.php

示例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);
 }
開發者ID:theus77,項目名稱:ElasticMS,代碼行數:12,代碼來源:IconTextType.php

示例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'];
 }
開發者ID:hogosha,項目名稱:monitor,代碼行數:32,代碼來源:Validator.php

示例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);
     }
 }
開發者ID:Algatux,項目名稱:influxdb-bundle,代碼行數:11,代碼來源:AbstractInfluxChoiceType.php

示例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');
 }
開發者ID:MatthieuPresse,項目名稱:jarvis,代碼行數:8,代碼來源:ProjectConfiguration.php

示例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());
 }
開發者ID:tomhaj,項目名稱:guzzle-oauth2,代碼行數:8,代碼來源:AbstractGrantType.php

示例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);
 }
開發者ID:voov,項目名稱:Billingo-API-Connector,代碼行數:15,代碼來源:Request.php

示例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');
 }
開發者ID:symfony-cmf,項目名稱:tree-browser-bundle,代碼行數:10,代碼來源:TreeSelectType.php

示例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]);
 }
開發者ID:rollerworks,項目名稱:datagrid,代碼行數:11,代碼來源:BaseType.php

示例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']);
 }
開發者ID:ThomasCantonnet,項目名稱:GoogleMapsApi,代碼行數:23,代碼來源:GeocodeService.php

示例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);
 }
開發者ID:silviomessi,項目名稱:sliderbundle,代碼行數:53,代碼來源:Slider.php

示例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']);
 }
開發者ID:ThomasCantonnet,項目名稱:GoogleMapsApi,代碼行數:23,代碼來源:PlacesService.php

示例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']);
 }
開發者ID:integratedfordevelopers,項目名稱:integrated-channel-bundle,代碼行數:18,代碼來源:ChannelChoiceType.php

示例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);
 }
開發者ID:stepansib,項目名稱:ldap,代碼行數:11,代碼來源:LDAP.php


注:本文中的Symfony\Component\OptionsResolver\OptionsResolver::setDefault方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。