本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolverInterface::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolverInterface::setDefault方法的具体用法?PHP OptionsResolverInterface::setDefault怎么用?PHP OptionsResolverInterface::setDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolverInterface
的用法示例。
在下文中一共展示了OptionsResolverInterface::setDefault方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
if ($this->autoGenerate) {
$resolver->setDefault('label_add', true);
$resolver->setDefault('label_delete', true);
}
}
示例2: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefined('entityName');
$resolver->setRequired('entityName');
$resolver->setAllowedTypes('entityName', 'string');
$resolver->setDefault('invalid_message', function (Options $options) {
return 'This value is not valid. Unable to find ' . $options['entityName'] . ' in the database.';
});
}
示例3: setDefaultOptions
/**
* {@inheritdoc}
*/
protected function setDefaultOptions(OptionsResolverInterface $resolver)
{
$dateNormalizer = function (Options $options, $value) {
if (is_string($value)) {
return new DateTime($value);
} elseif (is_numeric($value)) {
return DateTime::createFromFormat("U", $value);
}
return $value;
};
$resolver->setDefault("end", function (Options $options) {
return new Datetime();
})->setRequired(array("start", "end"))->setAllowedTypes("start", array("int", "string", "DateTime"))->setAllowedTypes("end", array("int", "string", "DateTime"))->setNormalizer("start", $dateNormalizer)->setNormalizer("end", $dateNormalizer);
}
示例4: setDefaultOptions
/**
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $options)
{
$options->setDefault('compound', false);
}
示例5: setDefaultOptions
/**
* @param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
*
* @return void
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
if ($this->getDataClass() instanceof TransferInterface && !$this->getDataClass() instanceof NullFormTransfer) {
$resolver->setDefault('data_class', get_class($this->getDataClass()));
}
}
示例6: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefault(array('attr' => array('class' => 'ckeditor')));
}
示例7: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefault('data_class', 'DP\\Core\\CoreBundle\\Settings\\Settings');
}