PEAR2_Templates_Savant_Turbo › PEAR2_Templates_Savant_Turbo-0.1.0/doc/pear2.php.net/PEAR2_Templates_Savant_Turbo/examples/examples/basic.php
- PEAR2_Templates_Savant_Turbo-0.1.0/
- doc/
- pear2.php.net/
- PEAR2_Templates_Savant_Turbo/
- examples/
- examples/
- examples/
- PEAR2_Templates_Savant_Turbo/
- pear2.php.net/
- php/
- PEAR2/
- Autoload.php
- Exception.php
- MultiErrors/
- MultiErrors.php
- Templates/
- Savant/
- PEAR2/
- doc/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
require_once __DIR__ . '/../vendor/php/PEAR2/Autoload.php';
PEAR2\Autoload::initialize(__DIR__ . '/../src');
use PEAR2\Templates\Savant;
/**
* Instead of constructing a Savant\Main object, construct a
* Savant\Turbo method.
*
* @var \PEAR2\Templates\Savant\Turbo\Main
*/
$savant = new Savant\Turbo\Main();
/**
* The following line is optional, but can be called if you need to customize
* the Cache_Lite settings.
*
* For testing on development machines, you can use a Mock caching driver:
* $savant->setCacheInterface(new Savant\Turbo\CacheInterface\Mock());
*/
$savant->setCacheInterface(new Savant\Turbo\CacheInterface\CacheLite());
/**
* Construct your object that implements CacheableInterface
*
* @see \PEAR2\Templates\Savant\Turbo\CacheableInterface
* @var Foo
*/
class CacheableObject implements Savant\Turbo\CacheableInterface
{
/**
* Return a unique caching key for this object
*
* @return string
*/
function getCacheKey()
{
return 'Foo object with ID#1';
}
/**
* This method is always called before any output is sent
*
* @param bool $cached
*/
function preRun($cached)
{
if ($cached) {
// cached output is about to be sent
}
// No cached output was available
// Set any headers that need to be sent etc
}
/**
* When non-cached output is sent, this method will be called
*/
function run()
{
}
}
$cacheableObject = new CacheableObject;
echo $savant->render($cacheableObject);
EOF
