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
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
24 * Filter all config values using the supplied Zend\Filter
26 * @param ZendFilter $filter
28 public function __construct(ZendFilter
$filter)
30 $this->setFilter($filter);
34 * @param ZendFilter $filter
37 public function setFilter(ZendFilter
$filter)
39 $this->filter
= $filter;
46 public function getFilter()
54 * @param Config $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');
65 * Walk through config and replace values
67 foreach ($config as $key => $val) {
68 if ($val instanceof Config
) {
71 $config->$key = $this->filter
->filter($val);
79 * Process a single value
84 public function processValue($value)
86 return $this->filter
->filter($value);