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-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license   http://framework.zend.com/license/new-bsd New BSD License
8 */
9
10namespace Zend\View\Model;
11
12use Countable;
13use IteratorAggregate;
14
15/**
16 * Interface describing a view model.
17 *
18 * Extends "Countable"; count() should return the number of children attached
19 * to the model.
20 *
21 * Extends "IteratorAggregate"; should allow iterating over children.
22 */
23interface ModelInterface extends Countable, IteratorAggregate
24{
25    /**
26     * Set renderer option/hint
27     *
28     * @param  string $name
29     * @param  mixed $value
30     * @return ModelInterface
31     */
32    public function setOption($name, $value);
33
34    /**
35     * Set renderer options/hints en masse
36     *
37     * @param  array|\Traversable $options
38     * @return ModelInterface
39     */
40    public function setOptions($options);
41
42    /**
43     * Get renderer options/hints
44     *
45     * @return array|\Traversable
46     */
47    public function getOptions();
48
49    /**
50     * Get a single view variable
51     *
52     * @param  string       $name
53     * @param  mixed|null   $default (optional) default value if the variable is not present.
54     * @return mixed
55     */
56    public function getVariable($name, $default = null);
57
58    /**
59     * Set view variable
60     *
61     * @param  string $name
62     * @param  mixed $value
63     * @return ModelInterface
64     */
65    public function setVariable($name, $value);
66
67    /**
68     * Set view variables en masse
69     *
70     * @param  array|\ArrayAccess $variables
71     * @return ModelInterface
72     */
73    public function setVariables($variables);
74
75    /**
76     * Get view variables
77     *
78     * @return array|\ArrayAccess
79     */
80    public function getVariables();
81
82    /**
83     * Set the template to be used by this model
84     *
85     * @param  string $template
86     * @return ModelInterface
87     */
88    public function setTemplate($template);
89
90    /**
91     * Get the template to be used by this model
92     *
93     * @return string
94     */
95    public function getTemplate();
96
97    /**
98     * Add a child model
99     *
100     * @param  ModelInterface $child
101     * @param  null|string $captureTo Optional; if specified, the "capture to" value to set on the child
102     * @param  null|bool $append Optional; if specified, append to child  with the same capture
103     * @return ModelInterface
104     */
105    public function addChild(ModelInterface $child, $captureTo = null, $append = false);
106
107    /**
108     * Return all children.
109     *
110     * Return specifies an array, but may be any iterable object.
111     *
112     * @return array
113     */
114    public function getChildren();
115
116    /**
117     * Does the model have any children?
118     *
119     * @return bool
120     */
121    public function hasChildren();
122
123    /**
124     * Set the name of the variable to capture this model to, if it is a child model
125     *
126     * @param  string $capture
127     * @return ModelInterface
128     */
129    public function setCaptureTo($capture);
130
131    /**
132     * Get the name of the variable to which to capture this model
133     *
134     * @return string
135     */
136    public function captureTo();
137
138    /**
139     * Set flag indicating whether or not this is considered a terminal or standalone model
140     *
141     * @param  bool $terminate
142     * @return ModelInterface
143     */
144    public function setTerminal($terminate);
145
146    /**
147     * Is this considered a terminal or standalone model?
148     *
149     * @return bool
150     */
151    public function terminate();
152
153    /**
154     * Set flag indicating whether or not append to child  with the same capture
155     *
156     * @param  bool $append
157     * @return ModelInterface
158     */
159    public function setAppend($append);
160
161    /**
162     * Is this append to child  with the same capture?
163     *
164     * @return bool
165     */
166    public function isAppend();
167}
168