本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolver::setDefined方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolver::setDefined方法的具体用法?PHP OptionsResolver::setDefined怎么用?PHP OptionsResolver::setDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolver
的用法示例。
在下文中一共展示了OptionsResolver::setDefined方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureProperties
protected function configureProperties(OptionsResolver $resolver)
{
$resolver->setDefined('logfile')->setAllowedTypes('logfile', 'string');
$resolver->setDefined('logfile_maxbytes');
$this->configureByteProperty('logfile_maxbytes', $resolver);
$resolver->setDefined('logfile_backups');
$this->configureIntegerProperty('logfile_backups', $resolver);
$resolver->setDefined('loglevel')->setAllowedTypes('loglevel', 'string')->setAllowedValues('loglevel', ['critical', 'error', 'warn', 'info', 'debug', 'trace', 'blather']);
$resolver->setDefined('pidfile')->setAllowedTypes('pidfile', 'string');
// TODO: octal vs. decimal value
$resolver->setDefined('umask');
$this->configureIntegerProperty('umask', $resolver);
$resolver->setDefined('nodaemon');
$this->configureBooleanProperty('nodaemon', $resolver);
$resolver->setDefined('minfds');
$this->configureIntegerProperty('minfds', $resolver);
$resolver->setDefined('minprocs');
$this->configureIntegerProperty('minprocs', $resolver);
$resolver->setDefined('nocleanup');
$this->configureBooleanProperty('nocleanup', $resolver);
$resolver->setDefined('childlogdir')->setAllowedTypes('childlogdir', 'string');
$resolver->setDefined('user')->setAllowedTypes('user', 'string');
$resolver->setDefined('directory')->setAllowedTypes('directory', 'string');
$resolver->setDefined('strip_ansi');
$this->configureBooleanProperty('strip_ansi', $resolver);
$this->configureEnvironmentProperty($resolver);
$resolver->setDefined('identifier')->setAllowedTypes('identifier', 'string');
}
示例2: configureProperties
/**
* {@inheritdoc}
*/
protected function configureProperties(OptionsResolver $resolver)
{
$resolver->setDefined('supervisor.rpcinterface_factory')->setAllowedTypes('supervisor.rpcinterface_factory', 'string');
// Note: undocumented, based on examples
$resolver->setDefined('retries');
$this->configureIntegerProperty('retries', $resolver);
}
示例3: configureWeekMealOptions
/**
* Set up the configurations of options
* passed as argument into the following methods of this class :
* - getWeekDates
* - getWeekMeals
*/
private function configureWeekMealOptions()
{
$this->weekMealResolver->setDefined(array('date_day', 'without_pork', 'enable_next_week', 'days_ofweek_off', 'dates_off'));
$this->weekMealResolver->setAllowedTypes('date_day', \DateTimeInterface::class);
$this->weekMealResolver->setDefaults(array('without_pork' => false, 'enable_next_week' => false, 'days_ofweek_off' => array(Day::WEEK_WEDNESDAY), 'dates_off' => array()));
$this->weekMealResolver->setRequired(array('without_pork', 'date_day'));
}
示例4: __construct
public function __construct(array $defaultParameters = array())
{
$this->parametersResolver = new SymfonyResolver();
$this->parametersResolver->setDefaults(array_merge(array('currentPage' => 0, 'itemsPerPage' => 10), $defaultParameters))->setAllowedTypes('currentPage', 'int')->setAllowedTypes('itemsPerPage', 'int');
$this->filtersResolver = new SymfonyResolver();
$this->filtersResolver->setDefined(array('operator', 'value', 'sort'))->setDefaults(array('sort_priority' => 0, 'parsed' => false, 'sorted' => false))->setAllowedValues('sort', array(null, 'asc', 'desc'))->setAllowedValues('operator', array_merge(array(null), Operations::getTextOperators(), Operations::getChoiceOperators(), Operations::getDateTimeOperators()))->setAllowedTypes('sort_priority', 'int');
}
示例5: configureOptions
/**
* Configure adapter options
*
* @param OptionsResolver $resolver
* @throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefined('digest_domains')->setAllowedTypes('digest_domains', 'string');
$resolver->setDefined('nonce_timeout')->setAllowedTypes('nonce_timeout', 'int');
$resolver->setDefault('use_opaque', false)->setAllowedTypes('use_opaque', 'bool');
$resolver->setDefault('algorithm', 'MD5')->setAllowedTypes('algorithm', 'string');
}
示例6: __construct
public function __construct(\Doctrine\ORM\EntityManager $em, \Doctrine\ORM\Mapping\ClassMetadata $class)
{
$this->resolverGetEleves = new OptionsResolver();
$this->resolverGetEleves->setDefined(array('school_id', 'date_day', 'activity_type'));
$this->resolverGetEleves->setAllowedTypes('date_day', \DateTimeInterface::class);
$this->resolverGetEleves->setDefaults(array('school_id' => 0));
parent::__construct($em, $class);
}
示例7: configureProperties
/**
* {@inheritdoc}
*/
protected function configureProperties(OptionsResolver $resolver)
{
$resolver->setDefined('serverurl')->setAllowedTypes('serverurl', 'string');
$resolver->setDefined('username')->setAllowedTypes('username', 'string');
$resolver->setDefined('password')->setAllowedTypes('password', 'string');
$resolver->setDefined('prompt')->setAllowedTypes('prompt', 'string');
$resolver->setDefined('history_file')->setAllowedTypes('history_file', 'string');
}
示例8: configureOptions
/**
* Configure adapter options
*
* @param OptionsResolver $resolver
* @throws \Symfony\Component\OptionsResolver\Exception\AccessException
* @throws \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('table_name')->setAllowedTypes('table_name', ['string']);
$resolver->setRequired('identity_column')->setAllowedTypes('identity_column', ['string']);
$resolver->setRequired('credential_column')->setAllowedTypes('credential_column', ['string']);
$resolver->setDefined('roles_column')->setAllowedTypes('roles_column', ['string', 'null']);
$resolver->setDefined('salt_column')->setAllowedTypes('salt_column', ['string', 'null']);
$resolver->setDefault('use_ambiguity_identity', false)->setAllowedTypes('use_ambiguity_identity', ['bool']);
}
示例9: configureProperties
/**
* {@inheritdoc}
*/
protected function configureProperties(OptionsResolver $resolver)
{
$resolver->setDefined('file')->setAllowedTypes('file', 'string');
// TODO: octal vs. decimal value
$resolver->setDefined('chmod')->setAllowedTypes('chmod', 'int');
$resolver->setDefined('chown')->setAllowedTypes('chown', 'string');
$resolver->setDefined('username')->setAllowedTypes('username', 'string');
$resolver->setDefined('password')->setAllowedTypes('password', ['string', 'numeric']);
}
示例10: configureProperties
/**
* {@inheritdoc}
*/
protected function configureProperties(OptionsResolver $resolver)
{
$resolver->setDefined('file')->setAllowedTypes('file', 'string');
// TODO: octal vs. decimal value
$resolver->setDefined('chmod');
$this->configureIntegerProperty('chmod', $resolver);
$resolver->setDefined('chown')->setAllowedTypes('chown', 'string');
$resolver->setDefined('username')->setAllowedTypes('username', 'string');
$resolver->setDefined('password')->setAllowedTypes('password', 'string');
}
示例11: configureProperties
/**
* {@inheritdoc}
*/
protected function configureProperties(OptionsResolver $resolver)
{
$resolver->setRequired('port')->setAllowedTypes('port', ['integer', 'string'])->setNormalizer('port', function (Options $options, $value) {
// We cast it to integer first to make sure it is an integer representation
is_numeric($value) and $value = '*:' . intval($value);
return $value;
});
$resolver->setDefined('username')->setAllowedTypes('username', 'string');
$resolver->setDefined('password')->setAllowedTypes('password', ['string', 'numeric']);
}
示例12: getConfigurableOptions
/**
* @return OptionsResolver
*/
public function getConfigurableOptions()
{
$resolver = new OptionsResolver();
$resolver->setDefined('clover_file');
$resolver->setDefined('level');
$resolver->addAllowedTypes('clover_file', ['string']);
$resolver->addAllowedTypes('level', ['int', 'float']);
$resolver->setDefaults(['level' => 100]);
$resolver->setRequired('clover_file');
return $resolver;
}
示例13: resolveOptions
/**
* 合并和校验参数
*/
public function resolveOptions()
{
$defaults = array('nonce_str' => Util::getRandomString(), 'client_ip' => Util::getClientIp());
$resolver = new OptionsResolver();
$resolver->setDefined($this->required)->setRequired($this->required)->setDefaults($defaults);
return $resolver->resolve($this->toArray());
}
示例14:
function it_defines_an_assigned_data_class(OptionsResolver $resolver)
{
$resolver->setDefaults(['data_class' => 'PromotionRule', 'validation_groups' => ['Default']])->shouldBeCalled();
$resolver->setDefined(['configuration_type'])->shouldBeCalled();
$resolver->setDefaults(['configuration_type' => ItemTotalRuleChecker::TYPE])->shouldBeCalled();
$this->configureOptions($resolver);
}
示例15: configureOptions
/**
* Configure options
*
* @param OptionsResolver $resolver
* @return void
*/
protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired(['amount']);
$resolver->setDefined(['currency', 'terminal', 'credit_card_token', 'payment_id']);
$resolver->setAllowedTypes('credit_card_token', 'string');
$resolver->setAllowedTypes('payment_id', 'string');
$resolver->setNormalizer('currency', function (Options $options, $value) {
if (!isset($options['payment_id'])) {
$fields = ['terminal', 'credit_card_token', 'currency'];
foreach ($fields as $field) {
if (!isset($options[$field])) {
throw new \InvalidArgumentException(sprintf('The fields "%s" is required', implode(', ', $fields)));
}
}
}
return $value;
});
$resolver->setNormalizer('payment_id', function (Options $options, $value) {
$fields = ['currency', 'terminal', 'credit_card_token'];
foreach ($fields as $field) {
if (isset($options[$field])) {
throw new \InvalidArgumentException(sprintf('The fields "%s" is not allowed when "payment_id" is set', implode(', ', $fields)));
}
}
return $value;
});
}