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 / View / Renderer / ConsoleRenderer.php
blob8b08ad6cbd2cd1512ea2754d16a135deb2d53efc
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\View\Renderer;
12 use Zend\Filter\FilterChain;
13 use Zend\View\Model\ModelInterface;
14 use Zend\View\Resolver\ResolverInterface;
16 /**
17 * Abstract class for Zend_View to help enforce private constructs.
19 * Note: all private variables in this class are prefixed with "__". This is to
20 * mark them as part of the internal implementation, and thus prevent conflict
21 * with variables injected into the renderer.
23 class ConsoleRenderer implements RendererInterface, TreeRendererInterface
25 /**
26 * @var FilterChain
28 protected $__filterChain;
30 /**
31 * Constructor.
34 * @todo handle passing helper manager, options
35 * @todo handle passing filter chain, options
36 * @todo handle passing variables object, options
37 * @todo handle passing resolver object, options
38 * @param array $config Configuration key-value pairs.
40 public function __construct($config = array())
42 $this->init();
45 public function setResolver(ResolverInterface $resolver)
47 return $this;
50 /**
51 * Return the template engine object
53 * Returns the object instance, as it is its own template engine
55 * @return PhpRenderer
57 public function getEngine()
59 return $this;
62 /**
63 * Allow custom object initialization when extending Zend_View_Abstract or
64 * Zend_View
66 * Triggered by {@link __construct() the constructor} as its final action.
68 * @return void
70 public function init()
74 /**
75 * Set filter chain
77 * @param FilterChain $filters
78 * @return ConsoleRenderer
80 public function setFilterChain(FilterChain $filters)
82 $this->__filterChain = $filters;
83 return $this;
86 /**
87 * Retrieve filter chain for post-filtering script content
89 * @return FilterChain
91 public function getFilterChain()
93 if (null === $this->__filterChain) {
94 $this->setFilterChain(new FilterChain());
96 return $this->__filterChain;
99 /**
100 * Recursively processes all ViewModels and returns output.
102 * @param string|ModelInterface $model A ViewModel instance.
103 * @param null|array|\Traversable $values Values to use when rendering. If none
104 * provided, uses those in the composed
105 * variables container.
106 * @return string Console output.
108 public function render($model, $values = null)
110 if (!$model instanceof ModelInterface) {
111 return '';
114 $result = '';
115 $options = $model->getOptions();
116 foreach ($options as $setting => $value) {
117 $method = 'set' . $setting;
118 if (method_exists($this, $method)) {
119 $this->$method($value);
121 unset($method, $setting, $value);
123 unset($options);
125 $values = $model->getVariables();
127 if (isset($values['result'])) {
128 // filter and append the result
129 $result .= $this->getFilterChain()->filter($values['result']);
132 if ($model->hasChildren()) {
133 // recursively render all children
134 foreach ($model->getChildren() as $child) {
135 $result .= $this->render($child, $values);
139 return $result;
143 * @see Zend\View\Renderer\TreeRendererInterface
144 * @return bool
146 public function canRenderTrees()
148 return true;