Example #1
0
 /**
  * Process the whole config structure with each parser in the queue.
  *
  * @param  Config $config
  * @return Config
  * @throws Exception\InvalidArgumentException
  */
 public function process(Config $config)
 {
     if ($config->isReadOnly()) {
         throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
     }
     foreach ($this as $parser) {
         /** @var $parser ProcessorInterface */
         $parser->process($config);
     }
 }
Example #2
0
 /**
  * Process
  * 
  * @param  Config $config
  * @return Config
  * @throws Exception\InvalidArgumentException
  */
 public function process(Config $config)
 {
     if ($config->isReadOnly()) {
         throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
     }
     /**
      * Walk through config and replace values
      */
     foreach ($config as $key => $val) {
         if ($val instanceof Config) {
             $this->process($val);
         } else {
             $config->{$key} = $this->filter->filter($val);
         }
     }
     return $config;
 }
Example #3
0
 /**
  * Process
  *
  * @param  Config $config
  * @return Config
  * @throws InvalidArgumentException
  */
 public function process(Config $config)
 {
     if ($config->isReadOnly()) {
         throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
     }
     if ($this->map === null) {
         $this->buildMap();
     }
     /**
      * Walk through config and replace values
      */
     $keys = array_keys($this->map);
     $values = array_values($this->map);
     foreach ($config as $key => $val) {
         if ($val instanceof Config) {
             $this->process($val);
         } else {
             $config->{$key} = str_replace($keys, $values, $val);
         }
     }
     return $config;
 }
Example #4
0
 /**
  * @group ZF-4728
  *
  */
 public function testSetReadOnlyAppliesToChildren()
 {
     $config = new Config($this->all, true);
     $config->setReadOnly();
     $this->assertTrue($config->isReadOnly());
     $this->assertTrue($config->one->isReadOnly(), 'First level children are writable');
     $this->assertTrue($config->one->two->isReadOnly(), 'Second level children are writable');
 }
Example #5
0
    /**
     * Process
     *
     * @param Config $config
     * @return Config
     * @throws InvalidArgumentException
     */
    public function process(Config $config)
    {
        if ($config->isReadOnly()) {
            throw new InvalidArgumentException('Cannot parse config because it is read-only');
        }

        /**
         * Walk through config and replace values
         */
        foreach ($config as $key => $val) {
            if ($val instanceof Config) {
                $this->process($val);
            } else {
                $config->$key = $this->translator->translate($val, $this->locale);
            }
        }

        return $config;
    }