]> git.mxchange.org Git - friendica.git/blob - library/Smarty/libs/sysplugins/smarty_config_source.php
Changes in api
[friendica.git] / library / Smarty / libs / sysplugins / smarty_config_source.php
1 <?php
2 /**
3  * Smarty Internal Plugin
4  *
5  * @package    Smarty
6  * @subpackage TemplateResources
7  */
8
9 /**
10  * Smarty Resource Data Object
11  * Meta Data Container for Config Files
12  *
13  * @package    Smarty
14  * @subpackage TemplateResources
15  * @author     Rodney Rehm
16  * @property string $content
17  * @property int    $timestamp
18  * @property bool   $exists
19  */
20 class Smarty_Config_Source extends Smarty_Template_Source
21 {
22     /**
23      * create Config Object container
24      *
25      * @param Smarty_Resource $handler         Resource Handler this source object communicates with
26      * @param Smarty          $smarty          Smarty instance this source object belongs to
27      * @param string          $resource        full config_resource
28      * @param string          $type            type of resource
29      * @param string          $name            resource name
30      * @param string          $unique_resource unqiue resource name
31      */
32     public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource)
33     {
34         $this->handler = $handler; // Note: prone to circular references
35
36         // Note: these may be ->config_compiler_class etc in the future
37         //$this->config_compiler_class = $handler->config_compiler_class;
38         //$this->config_lexer_class = $handler->config_lexer_class;
39         //$this->config_parser_class = $handler->config_parser_class;
40
41         $this->smarty = $smarty;
42         $this->resource = $resource;
43         $this->type = $type;
44         $this->name = $name;
45         $this->unique_resource = $unique_resource;
46     }
47
48     /**
49      * <<magic>> Generic setter.
50      *
51      * @param  string $property_name valid: content, timestamp, exists
52      * @param  mixed  $value         newly assigned value (not check for correct type)
53      *
54      * @throws SmartyException when the given property name is not valid
55      */
56     public function __set($property_name, $value)
57     {
58         switch ($property_name) {
59             case 'content':
60             case 'timestamp':
61             case 'exists':
62                 $this->$property_name = $value;
63                 break;
64
65             default:
66                 throw new SmartyException("invalid config property '$property_name'.");
67         }
68     }
69
70     /**
71      * <<magic>> Generic getter.
72      *
73      * @param  string $property_name valid: content, timestamp, exists
74      *
75      * @return mixed|void
76      * @throws SmartyException when the given property name is not valid
77      */
78     public function __get($property_name)
79     {
80         switch ($property_name) {
81             case 'timestamp':
82             case 'exists':
83                 $this->handler->populateTimestamp($this);
84
85                 return $this->$property_name;
86
87             case 'content':
88                 return $this->content = $this->handler->getContent($this);
89
90             default:
91                 throw new SmartyException("config property '$property_name' does not exist.");
92         }
93     }
94 }