Conditions | 5 |
Paths | 8 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function getContent($key, $callback) |
||
22 | { |
||
23 | $cache = $this->getCache(); |
||
24 | |||
25 | // Return cached value if available |
||
26 | $cacheEnabled = Config::inst()->get(get_class(), 'cache_enabled'); |
||
27 | $result = (isset($_GET['flush']) || !$cacheEnabled) |
||
28 | ? null |
||
29 | : $cache->get($key); |
||
30 | if ($result) { |
||
31 | return $result; |
||
32 | } |
||
33 | |||
34 | // Fallback to generate result |
||
35 | $result = parent::getContent($key, $callback); |
||
36 | $lifetime = Config::inst()->get(ContentFilter::class, 'cache_lifetime') ?: null; |
||
37 | $cache->set($key, $result, $lifetime); |
||
38 | return $result; |
||
39 | } |
||
41 |