1 | <?php |
||
8 | abstract class Fragment_Cache { |
||
9 | |||
10 | /** @var bool $in_callback Static flag to catch and prevent nested caching calls. */ |
||
11 | static $in_callback = false; |
||
|
|||
12 | |||
13 | /** @var int $timeout Cache timeout duration. */ |
||
14 | public $timeout; |
||
15 | |||
16 | /** @var string $type Handler type name. */ |
||
17 | protected $type; |
||
18 | |||
19 | /** |
||
20 | * Create object and set parameters from passed. |
||
21 | * |
||
22 | * @param array $args Configuration arguments. |
||
23 | */ |
||
24 | public function __construct( $args ) { |
||
29 | |||
30 | /** |
||
31 | * Enable fragment handler. |
||
32 | */ |
||
33 | abstract public function enable(); |
||
34 | |||
35 | /** |
||
36 | * Disable fragment handler. |
||
37 | */ |
||
38 | abstract public function disable(); |
||
39 | |||
40 | /** |
||
41 | * Wrapper to retrieve data through TLC Transient. |
||
42 | * |
||
43 | * @param string $name Name of fragment. |
||
44 | * @param array $args Arguments. |
||
45 | * @param mixed $salt Optional salt data. |
||
46 | * |
||
47 | * @return mixed |
||
48 | */ |
||
49 | public function fetch( $name, $args, $salt = '' ) { |
||
82 | |||
83 | /** |
||
84 | * Wraps callback to correctly set execution flag. |
||
85 | * |
||
86 | * @param string $name Fragment name. |
||
87 | * @param array $args Arguments. |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | public function wrap_callback( $name, $args ) { |
||
99 | |||
100 | /** |
||
101 | * Used to generate data to be cached. |
||
102 | * |
||
103 | * @param string $name Fragment name. |
||
104 | * @param array $args Arguments. |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | abstract protected function callback( $name, $args ); |
||
109 | |||
110 | /** |
||
111 | * Get human-readable HTML comment with timestamp to append to cached fragment. |
||
112 | * |
||
113 | * @param string $name Fragment name. |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | public function get_comment( $name ) { |
||
121 | } |
||
122 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.