Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Config / Processor / Filter.php
blob7740a26cbd8dccbd7cafbd84561b25ea18f800f7
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Config\Processor;
12 use Zend\Config\Config;
13 use Zend\Config\Exception;
14 use Zend\Filter\FilterInterface as ZendFilter;
16 class Filter implements ProcessorInterface
18 /**
19 * @var ZendFilter
21 protected $filter;
23 /**
24 * Filter all config values using the supplied Zend\Filter
26 * @param ZendFilter $filter
28 public function __construct(ZendFilter $filter)
30 $this->setFilter($filter);
33 /**
34 * @param ZendFilter $filter
35 * @return Filter
37 public function setFilter(ZendFilter $filter)
39 $this->filter = $filter;
40 return $this;
43 /**
44 * @return ZendFilter
46 public function getFilter()
48 return $this->filter;
51 /**
52 * Process
54 * @param Config $config
55 * @return Config
56 * @throws Exception\InvalidArgumentException
58 public function process(Config $config)
60 if ($config->isReadOnly()) {
61 throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
64 /**
65 * Walk through config and replace values
67 foreach ($config as $key => $val) {
68 if ($val instanceof Config) {
69 $this->process($val);
70 } else {
71 $config->$key = $this->filter->filter($val);
75 return $config;
78 /**
79 * Process a single value
81 * @param mixed $value
82 * @return mixed
84 public function processValue($value)
86 return $this->filter->filter($value);