本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolverInterface::setDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolverInterface::setDefaults方法的具体用法?PHP OptionsResolverInterface::setDefaults怎么用?PHP OptionsResolverInterface::setDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolverInterface
的用法示例。
在下文中一共展示了OptionsResolverInterface::setDefaults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
function it_should_define_assigned_data_class(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Rule', 'validation_groups' => array('sylius')))->shouldBeCalled();
$resolver->setOptional(array('configuration_type'))->shouldBeCalled();
$resolver->setDefaults(array('configuration_type' => RuleInterface::TYPE_ITEM_TOTAL))->shouldBeCalled();
$this->setDefaultOptions($resolver);
}
示例2: __construct
/**
* @param EventDispatcherInterface $dispatcher
*/
public function __construct(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
$this->specResolver = new OptionsResolver;
$this->specResolver->setDefaults(
array(
'on' => self::ALL,
'from' => self::ALL,
'to' => self::ALL,
'exclude_from' => array(),
'exclude_to' => array(),
)
);
$this->specResolver->setAllowedTypes(
array(
'on' => array('string', 'array'),
'from' => array('string', 'array'),
'to' => array('string', 'array'),
'exclude_from' => array('string', 'array'),
'exclude_to' => array('string', 'array'),
)
);
$toArrayNormalizer = function (Options $options, $value) {
return (array)$value;
};
$this->specResolver->setNormalizers(
array(
'on' => $toArrayNormalizer,
'from' => $toArrayNormalizer,
'to' => $toArrayNormalizer,
'exclude_to' => $toArrayNormalizer,
'exclude_from' => $toArrayNormalizer,
)
);
}
示例3: consume
/**
* consume
*
* @param array $options Parameters sent to the processor
*
* @return void
*/
public function consume(array $options = array())
{
if (null !== $this->logger) {
$this->logger->debug(sprintf('Start consuming queue %s.', $this->messageProvider->getQueueName()));
}
$this->optionsResolver->setDefaults(array('poll_interval' => 50000));
if ($this->processor instanceof ConfigurableInterface) {
$this->processor->setDefaultOptions($this->optionsResolver);
}
$options = $this->optionsResolver->resolve($options);
if ($this->processor instanceof InitializableInterface) {
$this->processor->initialize($options);
}
while (true) {
while (null !== ($message = $this->messageProvider->get())) {
if (false === $this->processor->process($message, $options)) {
break 2;
}
}
if ($this->processor instanceof SleepyInterface) {
if (false === $this->processor->sleep($options)) {
break;
}
}
usleep($options['poll_interval']);
}
if ($this->processor instanceof TerminableInterface) {
$this->processor->terminate($options);
}
}
示例4: array
function it_should_define_assigned_data_class(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Action', 'validation_groups' => array('sylius')))->shouldBeCalled();
$resolver->setOptional(array('configuration_type'))->shouldBeCalled();
$resolver->setDefaults(array('configuration_type' => ActionInterface::TYPE_FIXED_DISCOUNT))->shouldBeCalled();
$this->setDefaultOptions($resolver);
}
示例5: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
if ($this->routeName != "miw_rest_user_newuser") {
$resolver->setDefaults(array('data_class' => $this->class, 'intention' => 'registration'));
} else {
$resolver->setDefaults(array('data_class' => $this->class, 'intention' => 'registration', 'csrf_protection' => false));
}
}
示例6: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
if ($this->editMode) {
$resolver->setDefaults(array('class' => 'FormaLibre\\ReservationBundle\\Entity\\Reservation', 'translation_domain' => 'reservation', 'constraints' => new ReservationModify()));
} else {
$resolver->setDefaults(array('class' => 'FormaLibre\\ReservationBundle\\Entity\\Reservation', 'translation_domain' => 'reservation', 'constraints' => new Reservation()));
}
}
示例7: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['praticiensChoices']);
$resolver->setDefaults(['praticiensChoices' => array()]);
$resolver->setRequired(['motifChoices']);
$resolver->setDefaults(['motifChoices' => array()]);
$resolver->setRequired(['echantillonChoices']);
$resolver->setDefaults(['echantillonChoices' => array()]);
}
示例8: configureAttributes
/**
* {@inheritdoc}
*/
public function configureAttributes(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['tip', 'direction']);
$resolver->setDefaults(['direction' => self::DOWN]);
$resolver->setOptional(['name', 'short_tip', 'retractable', 'default_state', 'property_path', 'transformer']);
$resolver->setDefaults(['name' => '', 'transformer' => null, 'property_path' => null, 'retractable' => function (Options $options) {
return isset($options['short_tip']) && strlen($options['short_tip']);
}]);
$resolver->setAllowedValues(array('direction' => [self::UP, self::DOWN], 'default_state' => [self::EXPANDED, self::RETRACTED]));
$resolver->setAllowedTypes(['tip' => 'string', 'direction' => 'string', 'short_tip' => 'string', 'retractable' => 'bool', 'default_state' => 'string']);
}
示例9: setDefaultOptions
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$data = array();
//Dans le cas de la modification $utilisateur envoyé en paramétre pour récupérer les roles, tous le reste est mappé automatiquement
if (!empty($this->utilisateur)) {
//Récupération des roles cochés sous forme de tableau compatible avec le paramétre dans de setDefaults
foreach ($this->utilisateur->getRoles() as $roleValue) {
array_push($data, $roleValue->getRole());
}
$resolver->setDefaults(array('choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_SUPER_ADMIN' => 'Super administrateur'), 'multiple' => true, 'expanded' => true, 'label' => 'Profils', 'required' => true, 'data' => $data));
} else {
$resolver->setDefaults(array('choices' => array('ROLE_USER' => 'Utilisateur', 'ROLE_ADMIN' => 'Administrateur', 'ROLE_SUPER_ADMIN' => 'Super administrateur'), 'multiple' => true, 'required' => true, 'expanded' => true));
}
}
示例10: array
function it_should_configure_the_resolver(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('format' => Argument::any(), 'language' => \Locale::getDefault(), 'leading_zero' => false))->shouldBeCalled();
$resolver->setOptional(array('placeholder', 'language', 'leading_zero'))->shouldBeCalled();
$resolver->setAllowedTypes(array('placeholder' => array('string'), 'language' => array('string'), 'leading_zero' => array('bool')))->shouldBeCalled();
$this->setDefaultOptions($resolver);
}
示例11: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$defaultFieldOptions = ['multiple' => true];
$resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
$resolver->setNormalizers(['class' => function (Options $options, $value) {
if ($value !== null) {
return $value;
}
if (empty($options['dictionary_code'])) {
throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
}
$class = ExtendHelper::buildEnumValueClassName($options['dictionary_code']);
if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
}
return $class;
}, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
if (isset($options['class'])) {
$nullValue = null;
if ($options->has('null_value')) {
$nullValue = $options->get('null_value');
}
$value['choices'] = $this->getChoices($options['class'], $nullValue);
} else {
$value['choices'] = [];
}
return array_merge($defaultFieldOptions, $value);
}]);
}
示例12: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('data_class' => 'Barbon\\HostedApi\\AppBundle\\Form\\Common\\Model\\BankAccount', 'validation_groups' => function (FormInterface $form) {
$validationGroup = new BankAccountValidationGroupSelector();
return $validationGroup->chooseGroups($form);
}));
}
示例13: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$emptyData = function (FormInterface $form, $clientData) {
return $clientData;
};
$resolver->setDefaults(array('value' => '1', 'empty_data' => $emptyData, 'compound' => false));
}
示例14: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$class = get_class($this);
$class = substr($class, strlen('Kaikmedia\\GalleryModule\\Form\\Features\\'));
$class = substr($class, 0, -strlen('Type'));
$resolver->setDefaults(['data_class' => 'Kaikmedia\\GalleryModule\\Features\\' . $class]);
}
示例15: configureAttributes
/**
* {@inheritdoc}
*/
public function configureAttributes(OptionsResolverInterface $resolver)
{
$resolver->setRequired(['name', 'label']);
$resolver->setOptional(['rows', 'comment', 'suffix', 'prefix', 'selector', 'wrap', 'class', 'css_attribute', 'max_length', 'error', 'rules', 'filters', 'dependencies', 'default', 'property_path', 'transformer']);
$resolver->setDefaults(['dependencies' => [], 'filters' => [], 'rules' => [], 'transformer' => null, 'property_path' => null]);
$resolver->setAllowedTypes(['name' => 'string', 'rows' => 'int', 'label' => 'string', 'comment' => 'string', 'suffix' => 'string', 'prefix' => 'string', 'selector' => 'string', 'wrap' => 'string', 'class' => 'string', 'css_attribute' => 'string', 'max_length' => 'integer', 'error' => 'string', 'filters' => 'array', 'rules' => 'array', 'dependencies' => 'array', 'default' => ['string', 'integer']]);
}