本文整理匯總了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');
}