コード例 #1
0
 /**
  * {@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());
 }
コード例 #3
0
ファイル: FilterBuilder.php プロジェクト: johnkrovitch/sam
 /**
  * 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
0
ファイル: TaskBuilder.php プロジェクト: johnkrovitch/sam
 /**
  * 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
0
ファイル: Validator.php プロジェクト: ndrx-io/profiler
 /**
  * @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
0
ファイル: Factory.php プロジェクト: yohang/calendr
 /**
  * @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));
 }