View.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  */
12 
13 /**
14  * View defines the interface for all view implementations.
15  *
16  * @author ingo herwig <ingo@wemove.com>
17  */
18 interface View {
19 
20  /**
21  * Assign a value to the view
22  * @param $name The variable name
23  * @param $value The value
24  */
25  public function setValue($name, $value);
26 
27  /**
28  * Get a value from the view
29  * @param $name The variable name
30  * @return Mixed
31  */
32  public function getValue($name);
33 
34  /**
35  * Get all values from the view
36  * @return Array
37  */
38  public function getValues();
39 
40  /**
41  * Clear all values in the view
42  */
43  public function clearAllValues();
44 
45  /**
46  * Render the given template
47  * @param $tplFile The template file
48  * @param $cacheId The id of the view (optional, @see Response::getCacheId()) (optional: default: null)
49  * @param $cacheLifetime The cache lifetime in seconds (optional, default: implementation specific)
50  * @param $display Boolean whether to output the result or return it (default: _true_)
51  */
52  public function render($tplFile, $cacheId=null, $cacheLifetime=null, $display=true);
53 
54  /**
55  * Clear the cache
56  * @param $tplFile The template file (optional, default: null), null to clear the complete cache
57  * @param $cacheId The id of the view (@see Controller::getCacheId()) (optional: default: null)
58  * @return Integer number of cache files deleted
59  */
60  public static function clearCache($tplFile=null, $cacheId=null);
61 
62  /**
63  * Check if a view is cached
64  * @param $tplFile The template file
65  * @param $cacheId The id of the view (@see Controller::getCacheId()) (optional: default: null)
66  */
67  public static function isCached($tplFile, $cacheId=null);
68 
69  /**
70  * Get the date of the cache entry, if the view is cached
71  * @param $tplFile The template file
72  * @param $cacheId The id of the view (@see Controller::getCacheId()) (optional: default: null)
73  * @return DateTime or null, if not cached
74  */
75  public static function getCacheDate($tplFile, $cacheId=null);
76 
77  /**
78  * Get the template filename for the view from the configfile for the given action key.
79  * @param $controller The name of the controller
80  * @param $context The name of the context
81  * @param $action The name of the action
82  * @return The filename of the template or false, if no view is defined
83  */
84  public static function getTemplate($controller, $context, $action);
85 }
86 ?>
static clearCache($tplFile=null, $cacheId=null)
Clear the cache.
render($tplFile, $cacheId=null, $cacheLifetime=null, $display=true)
Render the given template.
static isCached($tplFile, $cacheId=null)
Check if a view is cached.
clearAllValues()
Clear all values in the view.
getValues()
Get all values from the view.
static getTemplate($controller, $context, $action)
Get the template filename for the view from the configfile for the given action key.
setValue($name, $value)
Assign a value to the view.
View defines the interface for all view implementations.
Definition: View.php:18
getValue($name)
Get a value from the view.
static getCacheDate($tplFile, $cacheId=null)
Get the date of the cache entry, if the view is cached.