本文整理汇总了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')));
}
示例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);
}
示例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));
}
示例4: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->replaceDefaults(["required" => true, "constraints" => array(new NotBlank(), new Callback(["methods" => array([$this, "checkId"])])), "cascade_validation" => true]);
}
示例5: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->replaceDefaults(["cascade_validation" => true]);
}
示例6: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->replaceDefaults(array('years' => range(date('Y'), date('Y') + 9)));
}
示例7: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->replaceDefaults(["cascade_validation" => true, "constraints" => array(new Callback(["methods" => array([$this, "checkStateId"])]))]);
}
示例8: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->replaceDefaults(['validation_groups' => $this->getValidationGroups()]);
}