/** * {@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; }
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()); }
/** * 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; }
/** * 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; }
/** * @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; }
/** * @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)); }