Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  *
  * @throws ProcessorException If no processor is set.
  */
 public function getConfigTreeBuilder()
 {
     if (null === $this->last) {
         throw new ProcessorException('The support() method did not find a processor.');
     }
     return $this->last->getConfigTreeBuilder();
 }
Ejemplo n.º 2
0
 /**
  * Processes the configuration definition.
  *
  * @param array   $data     The configuration data.
  * @param mixed   $resource A resource.
  * @param string  $type     The resource type.
  * @param boolean $require  Require processing?
  *
  * @return array The processed configuration data.
  *
  * @throws ProcessorException If the processor could not be used and it is
  *                            require that one be used.
  */
 private function process(array $data, $resource, $type, $require)
 {
     if ($this->processor) {
         if ($this->processor instanceof ProcessorInterface) {
             if ($this->processor->supports($resource, $type)) {
                 $data = $this->processor->process($data);
             } elseif ($require) {
                 throw ProcessorException::format('The resource "%s"%s is not supported by the processor.', is_string($resource) ? $resource : gettype($resource), $type ? " ({$type})" : '');
             }
         } else {
             $processor = new Processor();
             $data = $processor->processConfiguration($this->processor, $data);
         }
     } elseif ($require) {
         throw ProcessorException::format('No processor registered to handle any resource.');
     }
     return $data;
 }