Queue.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. */
  9. namespace Zend\Config\Processor;
  10. use Zend\Config\Config;
  11. use Zend\Config\Exception;
  12. use Zend\Stdlib\PriorityQueue;
  13. class Queue extends PriorityQueue implements ProcessorInterface
  14. {
  15. /**
  16. * Process the whole config structure with each parser in the queue.
  17. *
  18. * @param Config $config
  19. * @return Config
  20. * @throws Exception\InvalidArgumentException
  21. */
  22. public function process(Config $config)
  23. {
  24. if ($config->isReadOnly()) {
  25. throw new Exception\InvalidArgumentException('Cannot process config because it is read-only');
  26. }
  27. foreach ($this as $parser) {
  28. /** @var $parser ProcessorInterface */
  29. $parser->process($config);
  30. }
  31. }
  32. /**
  33. * Process a single value
  34. *
  35. * @param mixed $value
  36. * @return mixed
  37. */
  38. public function processValue($value)
  39. {
  40. foreach ($this as $parser) {
  41. /** @var $parser ProcessorInterface */
  42. $value = $parser->processValue($value);
  43. }
  44. return $value;
  45. }
  46. }