当前位置: 首页>>代码示例>>PHP>>正文


PHP OptionsResolverInterface::replaceDefaults方法代码示例

本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolverInterface::replaceDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolverInterface::replaceDefaults方法的具体用法?PHP OptionsResolverInterface::replaceDefaults怎么用?PHP OptionsResolverInterface::replaceDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\OptionsResolver\OptionsResolverInterface的用法示例。


在下文中一共展示了OptionsResolverInterface::replaceDefaults方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setDefaultOptions

 /**
  * @param OptionsResolverInterface $resolver
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     strtotime('-25 days');
     $choices = array();
     $minDate = explode('-', date('Y-m', strtotime('-24 days')));
     $minDate = $minDate[0] * 12 + $minDate[1] - 1;
     $maxDate = $minDate;
     for ($date = $minDate; $date <= $maxDate; $date++) {
         $year = floor($date / 12);
         $month = $date % 12 + 1;
         $key = $year . '-' . sprintf($month, '%02d');
         $choices[$key] = ucwords($this->formatTimestamps(new \DateTime('01-' . $month . '-' . $year), 'YYYY MMMM'));
     }
     $resolver->replaceDefaults(array('day' => array(1), 'required' => false, 'choices' => $choices, 'attr' => array('class' => 'mois')));
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:18,代码来源:MoisType.php

示例2: setDefaultOptions

 /**
  * {@inheritdoc}
  *
  * The EntityChoiceList has been extended to sort choices
  *
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     // Set a default query_builder so our custom Loader is always used
     $queryBuilder = function (Options $options) {
         return $options['em']->getRepository($options['class'])->createQueryBuilder('e')->select('e');
     };
     // Set a custom Loader that will sort the entities if the option is set
     $type = $this;
     $loader = function (Options $options) use($type, $queryBuilder) {
         return $type->getLoader($options['em'], $options['query_builder'], $options['class'], $options['automatic_sorting']);
     };
     // Replace the default options with these new ones
     $resolver->replaceDefaults(array('query_builder' => $queryBuilder, 'loader' => $loader));
     // Add some custom default options
     $defaults = array('automatic_sorting' => true, 'add_select_all' => true);
     $resolver->setDefaults($defaults);
 }
开发者ID:pmdc,项目名称:UnifikSystemBundle,代码行数:23,代码来源:TreeChoiceType.php

示例3: setOption

 /**
  * @param string $name
  * @param mixed  $value
  */
 public function setOption($name, $value)
 {
     $this->resolver->replaceDefaults($this->options);
     $this->options = $this->resolver->resolve(array($name => $value));
 }
开发者ID:joostvanderborg,项目名称:CalendR,代码行数:9,代码来源:Factory.php

示例4: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->replaceDefaults(["required" => true, "constraints" => array(new NotBlank(), new Callback(["methods" => array([$this, "checkId"])])), "cascade_validation" => true]);
 }
开发者ID:badelas,项目名称:thelia,代码行数:4,代码来源:AbstractIdType.php

示例5: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->replaceDefaults(["cascade_validation" => true]);
 }
开发者ID:margery,项目名称:thelia,代码行数:4,代码来源:TaxRuleI18nType.php

示例6: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->replaceDefaults(array('years' => range(date('Y'), date('Y') + 9)));
 }
开发者ID:stupae,项目名称:Akins-Parker-MikeO-Brien,代码行数:4,代码来源:PaymentType.php

示例7: setDefaultOptions

 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->replaceDefaults(["cascade_validation" => true, "constraints" => array(new Callback(["methods" => array([$this, "checkStateId"])]))]);
 }
开发者ID:zorn-v,项目名称:thelia,代码行数:4,代码来源:CountryStateMigrationType.php

示例8: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->replaceDefaults(['validation_groups' => $this->getValidationGroups()]);
 }
开发者ID:CopeX,项目名称:crm,代码行数:7,代码来源:ChannelTypeExtension.php


注:本文中的Symfony\Component\OptionsResolver\OptionsResolverInterface::replaceDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。