本文整理汇总了PHP中Symfony\Component\OptionsResolver\OptionsResolver::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP OptionsResolver::clear方法的具体用法?PHP OptionsResolver::clear怎么用?PHP OptionsResolver::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\OptionsResolver\OptionsResolver
的用法示例。
在下文中一共展示了OptionsResolver::clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear
/**
* {@inheritDoc}
*/
public function clear()
{
parent::clear();
/* This must be done after the parent to ensure that the parent's locked state is enforced. */
$this->casts = [];
return $this;
}
示例2: testClearOptionAndNormalizer
public function testClearOptionAndNormalizer()
{
$this->resolver->setDefault('foo1', 'bar');
$this->resolver->setNormalizer('foo1', function (Options $options) {
return '';
});
$this->resolver->setDefault('foo2', 'bar');
$this->resolver->setNormalizer('foo2', function (Options $options) {
return '';
});
$this->resolver->clear();
$this->assertEmpty($this->resolver->resolve());
}
示例3: build
/**
* Build the filter with the given configuration.
*
* @param array $filterConfigurations
* @return FilterInterface[]
* @throws Exception
*/
public function build(array $filterConfigurations)
{
$resolver = new OptionsResolver();
$filters = [];
foreach ($filterConfigurations as $filterName => $filterConfiguration) {
$resolver->clear();
if ($filterConfiguration === null) {
$filterConfiguration = [];
}
$configuration = $this->getFilterConfiguration($filterName);
$configuration->configureOptions($resolver);
$configuration->setParameters($resolver->resolve($filterConfiguration));
$class = $this->mapping[$filterName];
/** @var FilterInterface $filter */
$filter = new $class($filterName, $configuration, $this->eventDispatcher);
$filter->checkRequirements();
$filters[$filterName] = $filter;
}
return $filters;
}
示例4: build
/**
* Build and return an array of Task.
*
* @param array $taskConfigurations
* @return Task[]
*/
public function build(array $taskConfigurations)
{
$resolver = new OptionsResolver();
$tasks = [];
foreach ($taskConfigurations as $taskName => $taskConfiguration) {
$resolver->clear();
// debug mode
if ($this->debug === true) {
$taskConfiguration['debug'] = $this->debug;
}
// add copy filter in last position if required
if (!$this->hasCopyFilter($taskConfiguration)) {
$taskConfiguration['filters'][] = 'copy';
}
$configuration = new TaskConfiguration();
$configuration->configureOptions($resolver);
$configuration->setParameters($resolver->resolve($taskConfiguration));
$task = new Task($taskName, $configuration);
$tasks[$taskName] = $task;
}
return $tasks;
}
示例5: validate
/**
* @param array $data
* @throws UndefinedOptionsException If an option name is undefined
* @throws InvalidOptionsException If an option doesn't fulfill the
* specified validation rules
* @throws MissingOptionsException If a required option is missing
* @throws OptionDefinitionException If there is a cyclic dependency between
* lazy options and/or normalizers
* @throws NoSuchOptionException If a lazy option reads an unavailable option
* @throws AccessException If called from a lazy option or normalizer
* @return bool
*/
public function validate(array $data)
{
$this->optionResolver->resolve($data);
$this->optionResolver->clear();
return true;
}
示例6: setOption
/**
* @param string $name
* @param mixed $value
*/
public function setOption($name, $value)
{
$this->resolver->clear();
$this->resolver->setDefaults($this->options);
$this->options = $this->resolver->resolve(array($name => $value));
}