當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。