equal
deleted
inserted
replaced
12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Controller |
16 * @package Zend_Controller |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Cache.php 22662 2010-07-24 17:37:36Z mabe $ |
19 * @version $Id: Cache.php 24853 2012-05-31 23:19:27Z adamlundrigan $ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @see Zend_Controller_Action_Helper_Abstract |
23 * @see Zend_Controller_Action_Helper_Abstract |
24 */ |
24 */ |
35 require_once 'Zend/Cache/Manager.php'; |
35 require_once 'Zend/Cache/Manager.php'; |
36 |
36 |
37 /** |
37 /** |
38 * @category Zend |
38 * @category Zend |
39 * @package Zend_Controller |
39 * @package Zend_Controller |
40 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
40 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
41 * @license http://framework.zend.com/license/new-bsd New BSD License |
41 * @license http://framework.zend.com/license/new-bsd New BSD License |
42 */ |
42 */ |
43 class Zend_Controller_Action_Helper_Cache |
43 class Zend_Controller_Action_Helper_Cache |
44 extends Zend_Controller_Action_Helper_Abstract |
44 extends Zend_Controller_Action_Helper_Abstract |
45 { |
45 { |
62 * Indexed map of Tags by Controller and Action |
62 * Indexed map of Tags by Controller and Action |
63 * |
63 * |
64 * @var array |
64 * @var array |
65 */ |
65 */ |
66 protected $_tags = array(); |
66 protected $_tags = array(); |
67 |
67 |
68 /** |
68 /** |
69 * Indexed map of Extensions by Controller and Action |
69 * Indexed map of Extensions by Controller and Action |
70 * |
70 * |
71 * @var array |
71 * @var array |
72 */ |
72 */ |
128 * @return mixed |
128 * @return mixed |
129 */ |
129 */ |
130 public function removePage($relativeUrl, $recursive = false) |
130 public function removePage($relativeUrl, $recursive = false) |
131 { |
131 { |
132 $cache = $this->getCache(Zend_Cache_Manager::PAGECACHE); |
132 $cache = $this->getCache(Zend_Cache_Manager::PAGECACHE); |
|
133 $encodedCacheId = $this->_encodeCacheId($relativeUrl); |
|
134 |
133 if ($recursive) { |
135 if ($recursive) { |
134 $backend = $cache->getBackend(); |
136 $backend = $cache->getBackend(); |
135 if (($backend instanceof Zend_Cache_Backend) |
137 if (($backend instanceof Zend_Cache_Backend) |
136 && method_exists($backend, 'removeRecursively') |
138 && method_exists($backend, 'removeRecursively') |
137 ) { |
139 ) { |
138 return $backend->removeRecursively($relativeUrl); |
140 $result = $backend->removeRecursively($encodedCacheId); |
139 } |
141 if (is_null($result) ) { |
140 } |
142 $result = $backend->removeRecursively($relativeUrl); |
141 |
143 } |
142 return $cache->remove($relativeUrl); |
144 return $result; |
|
145 } |
|
146 } |
|
147 |
|
148 $result = $cache->remove($encodedCacheId); |
|
149 if (is_null($result) ) { |
|
150 $result = $cache->remove($relativeUrl); |
|
151 } |
|
152 return $result; |
143 } |
153 } |
144 |
154 |
145 /** |
155 /** |
146 * Remove a specific page cache static file based on its |
156 * Remove a specific page cache static file based on its |
147 * relative URL from the application's public directory. |
157 * relative URL from the application's public directory. |
187 } |
197 } |
188 $this->getCache(Zend_Cache_Manager::PAGECACHE) |
198 $this->getCache(Zend_Cache_Manager::PAGECACHE) |
189 ->start($this->_encodeCacheId($reqUri), $tags, $extension); |
199 ->start($this->_encodeCacheId($reqUri), $tags, $extension); |
190 } |
200 } |
191 } |
201 } |
192 |
202 |
193 /** |
203 /** |
194 * Encode a Cache ID as hexadecimal. This is a workaround because Backend ID validation |
204 * Encode a Cache ID as hexadecimal. This is a workaround because Backend ID validation |
195 * is trapped in the Frontend classes. Will try to get this reversed for ZF 2.0 |
205 * is trapped in the Frontend classes. Will try to get this reversed for ZF 2.0 |
196 * because it's a major annoyance to have IDs so restricted! |
206 * because it's a major annoyance to have IDs so restricted! |
197 * |
207 * |