ControllerMessage.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\presentation;
12 
14 
15 /**
16  * Messages are sent between Controllers and are used to transfer data between
17  * them. They are are dispatched by ActionMapper, which decides upon the
18  * message's controller, context and action parameter to which Controller it will
19  * be send.
20  *
21  * @author ingo herwig <ingo@wemove.com>
22  */
23 interface ControllerMessage {
24 
25  /**
26  * Set the name of the sending Controller
27  * @param $sender The name of the Controller
28  */
29  public function setSender($sender);
30 
31  /**
32  * Get the name of the sending Controller
33  * @return The name of the Controller
34  */
35  public function getSender();
36 
37  /**
38  * Set the name of the context
39  * @param $context The name of the context
40  */
41  public function setContext($context);
42 
43  /**
44  * Get the name of the context
45  * @return The name of the context
46  */
47  public function getContext();
48 
49  /**
50  * Set the name of the action
51  * @param $action The name of the action
52  */
53  public function setAction($action);
54 
55  /**
56  * Get the name of the action
57  * @return The name of the action
58  */
59  public function getAction();
60 
61  /**
62  * Set the message format
63  * @param $format A key of the configuration section 'Formats'
64  */
65  public function setFormat($format);
66 
67  /**
68  * Get the message format. If no explicit format is set, the
69  * format is derived from the Content-Type header value, if existing.
70  * If no format can be derived, the first format in the configuration
71  * section 'Formats' will be used.
72  * @return String
73  */
74  public function getFormat();
75 
76  /**
77  * Set a header value
78  * @param $name The header name
79  * @param $value The header value
80  */
81  public function setHeader($name, $value);
82 
83  /**
84  * Set all headers at once
85  * @param $headers The associative array
86  */
87  public function setHeaders(array $headers);
88 
89  /**
90  * Get a header value
91  * @param $name The header name
92  * @param $default The default value if the header is not defined (default: _null_)
93  * @return The header value or default, if it does not exist
94  */
95  public function getHeader($name, $default=null);
96 
97  /**
98  * Get all key headers
99  * @return An associative array
100  */
101  public function getHeaders() ;
102 
103  /**
104  * Remove a header
105  * @param $name The name of the header
106  */
107  public function clearHeader($name);
108 
109  /**
110  * Remove all headers
111  */
112  public function clearHeaders();
113 
114  /**
115  * Check for existence of a header
116  * @param $name The name of the header
117  * @return Boolean whether the header exists or not exist
118  */
119  public function hasHeader($name);
120 
121  /**
122  * Set a value
123  * @param $name The name of the variable
124  * @param $value The value of the variable
125  */
126  public function setValue($name, $value);
127 
128  /**
129  * Set all key value pairs at once
130  * @param $values The associative array
131  */
132  public function setValues(array $values);
133 
134  /**
135  * Get a value
136  * @param $name The name of the variable
137  * @param $default The default value if the value is not defined or invalid while exceptions are suppressed (optional, default: _null_)
138  * @param $validateDesc An validation description to be used with Validator::validate() (optional, default: _null_)
139  * @param $suppressException Boolean whether to suppress a validation exception or not (optional, default: _false_)
140  * @return The (filtered) value or default, if it does not exist
141  */
142  public function getValue($name, $default=null, $validateDesc=null, $suppressException=false);
143 
144  /**
145  * Get a value as boolean
146  * @param $name The name of the variable
147  * @param $default The default value if the value is not defined (default: _false_)
148  * @return The value or null if it does not exist
149  */
150  public function getBooleanValue($name, $default=false);
151 
152  /**
153  * Get all key value pairs
154  * @return An associative array
155  */
156  public function getValues();
157 
158  /**
159  * Remove a value
160  * @param $name The name of the variable
161  */
162  public function clearValue($name);
163 
164  /**
165  * Remove all values
166  */
167  public function clearValues();
168 
169  /**
170  * Check for existence of a value
171  * @param $name The name of the variable
172  * @return Boolean whether the value exists or not exist
173  */
174  public function hasValue($name);
175 
176  /**
177  * Set a property
178  * @param $name The name of the property
179  * @param $value The value of the property
180  */
181  public function setProperty($name, $value);
182 
183  /**
184  * Get a property
185  * @param $name The name of the property
186  * @return The property value or null
187  */
188  public function getProperty($name);
189 
190  /**
191  * Add an error to the list of errors.
192  * @param $error The error.
193  */
194  public function addError(ApplicationError $error);
195 
196  /**
197  * Set all errors at once
198  * @param $errors The errors array
199  */
200  public function setErrors(array $errors);
201 
202  /**
203  * Get all errors.
204  * @return An array of Error instances.
205  */
206  public function getErrors();
207 
208  /**
209  * Remove all errors
210  */
211  public function clearErrors();
212 
213  /**
214  * Check if errors exist.
215  * @return Boolean whether there are errors or not.
216  */
217  public function hasErrors();
218 }
219 ?>
setSender($sender)
Set the name of the sending Controller.
getSender()
Get the name of the sending Controller.
setHeaders(array $headers)
Set all headers at once.
setContext($context)
Set the name of the context.
getValues()
Get all key value pairs.
clearHeader($name)
Remove a header.
getContext()
Get the name of the context.
hasErrors()
Check if errors exist.
addError(ApplicationError $error)
Add an error to the list of errors.
getFormat()
Get the message format.
setAction($action)
Set the name of the action.
hasValue($name)
Check for existence of a value.
getAction()
Get the name of the action.
ApplicationError is used to signal errors that occur while processing a request.
setValues(array $values)
Set all key value pairs at once.
getValue($name, $default=null, $validateDesc=null, $suppressException=false)
Get a value.
setFormat($format)
Set the message format.
setProperty($name, $value)
Set a property.
setValue($name, $value)
Set a value.
Messages are sent between Controllers and are used to transfer data between them.
getBooleanValue($name, $default=false)
Get a value as boolean.
setErrors(array $errors)
Set all errors at once.
getHeader($name, $default=null)
Get a header value.
setHeader($name, $value)
Set a header value.
hasHeader($name)
Check for existence of a header.
Presentation related interfaces and classes.
Definition: namespaces.php:59