source: trunk/include/smarty/libs/sysplugins/smarty_config_source.php @ 23485

Last change on this file since 23485 was 23485, checked in by rvelices, 11 years ago

Smarty EOL style LF svn property

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