|
Revision 23810, 1.5 kB
(checked in by Kris.Wallsmith, 4 years ago)
|
[1.3] set svn:eol-style property to native and svn:keywords property to Id on all .php files
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 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 |
function cache($name, $lifeTime = 86400) |
|---|
| 31 |
{ |
|---|
| 32 |
if (!sfConfig::get('sf_cache')) |
|---|
| 33 |
{ |
|---|
| 34 |
return null; |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
$cache = sfContext::getInstance()->getViewCacheManager(); |
|---|
| 38 |
|
|---|
| 39 |
if (sfConfig::get('symfony.cache.started')) |
|---|
| 40 |
{ |
|---|
| 41 |
throw new sfCacheException('Cache already started.'); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
$data = $cache->start($name, $lifeTime); |
|---|
| 45 |
|
|---|
| 46 |
if (null === $data) |
|---|
| 47 |
{ |
|---|
| 48 |
sfConfig::set('symfony.cache.started', true); |
|---|
| 49 |
sfConfig::set('symfony.cache.current_name', $name); |
|---|
| 50 |
|
|---|
| 51 |
return false; |
|---|
| 52 |
} |
|---|
| 53 |
else |
|---|
| 54 |
{ |
|---|
| 55 |
echo $data; |
|---|
| 56 |
|
|---|
| 57 |
return true; |
|---|
| 58 |
} |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
function cache_save() |
|---|
| 62 |
{ |
|---|
| 63 |
if (!sfConfig::get('sf_cache')) |
|---|
| 64 |
{ |
|---|
| 65 |
return null; |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
if (!sfConfig::get('symfony.cache.started')) |
|---|
| 69 |
{ |
|---|
| 70 |
throw new sfCacheException('Cache not started.'); |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
$data = sfContext::getInstance()->getViewCacheManager()->stop(sfConfig::get('symfony.cache.current_name', '')); |
|---|
| 74 |
|
|---|
| 75 |
sfConfig::set('symfony.cache.started', false); |
|---|
| 76 |
sfConfig::set('symfony.cache.current_name', null); |
|---|
| 77 |
|
|---|
| 78 |
echo $data; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|