Definition at line 46 of file View.php.
◆ __construct()
Slim_View::__construct |
( |
| ) |
|
Constructor.
This is empty but may be overridden in a subclass
Definition at line 63 of file View.php.
◆ appendData()
Slim_View::appendData |
( |
array |
$data | ) |
|
Append data to existing View data.
- Parameters
-
- Returns
- void
Definition at line 113 of file View.php.
References data.
◆ display()
Slim_View::display |
( |
|
$template | ) |
|
Display template.
This method echoes the rendered template to the current output buffer
- Parameters
-
string | $template | Path to template file relative to templates directoy |
- Returns
- void
Definition at line 143 of file View.php.
References render().
render( $template)
Render template.
◆ getData()
Slim_View::getData |
( |
|
$key = null | ) |
|
Get data.
- Parameters
-
- Returns
- array|mixed|null All View data if no $key, value of datum if $key, or NULL if $key but datum does not exist.
Definition at line 72 of file View.php.
References $data, and data.
73 if ( !is_null($key) ) {
74 return isset($this->
data[$key]) ? $this->
data[$key] : null;
◆ getTemplatesDirectory()
Slim_View::getTemplatesDirectory |
( |
| ) |
|
Get templates directory.
- Returns
- string|null Path to templates directory without trailing slash
Definition at line 121 of file View.php.
References $templatesDirectory.
Referenced by render().
◆ render()
Slim_View::render |
( |
|
$template | ) |
|
Render template.
- Parameters
-
string | $template | Path to template file relative to templates directory |
- Returns
- string Rendered template
- Exceptions
-
RuntimeException | If template does not exist |
Definition at line 153 of file View.php.
References data, and getTemplatesDirectory().
Referenced by display().
154 extract($this->
data);
156 if ( !file_exists($templatePath) ) {
157 throw new RuntimeException(
'View cannot render template `' . $templatePath .
'`. Template does not exist.');
160 require $templatePath;
161 return ob_get_clean();
getTemplatesDirectory()
Get templates directory.
◆ setData()
Set data.
This method is overloaded to accept two different method signatures. You may use this to set a specific key with a specfic value, or you may use this to set all data to a specific array.
USAGE:
View::setData('color', 'red'); View::setData(array('color' => 'red', 'number' => 1));
- Parameters
-
string|array | |
mixed | Optional. Only use if first argument is a string. |
- Returns
- void
- Exceptions
-
InvalidArgumentException | If incorrect method signature |
Definition at line 97 of file View.php.
References data, and string.
98 $args = func_get_args();
99 if ( count($args) === 1 && is_array($args[0]) ) {
100 $this->
data = $args[0];
101 }
else if ( count($args) === 2 ) {
104 throw new InvalidArgumentException(
'Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
Add rich text string
The name of the decorator.
◆ setTemplatesDirectory()
Slim_View::setTemplatesDirectory |
( |
|
$dir | ) |
|
Set templates directory.
- Parameters
-
- Returns
- void
- Exceptions
-
RuntimeException | If directory is not a directory or does not exist |
Definition at line 131 of file View.php.
132 $this->templatesDirectory = rtrim($dir,
'/');
◆ $data
Slim_View::$data = array() |
|
protected |
◆ $templatesDirectory
Slim_View::$templatesDirectory |
|
protected |
The documentation for this class was generated from the following file:
- Services/WebServices/Rest/lib/Slim/View.php