web/lib/Zend/Cache/Frontend/Class.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    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_Cache
    16  * @package    Zend_Cache
    17  * @subpackage Zend_Cache_Frontend
    17  * @subpackage Zend_Cache_Frontend
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Class.php 23051 2010-10-07 17:01:21Z mabe $
    20  * @version    $Id: Class.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Cache_Core
    24  * @see Zend_Cache_Core
    25  */
    25  */
    27 
    27 
    28 
    28 
    29 /**
    29 /**
    30  * @package    Zend_Cache
    30  * @package    Zend_Cache
    31  * @subpackage Zend_Cache_Frontend
    31  * @subpackage Zend_Cache_Frontend
    32  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    32  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    33  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    33  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    34  */
    34  */
    35 class Zend_Cache_Frontend_Class extends Zend_Cache_Core
    35 class Zend_Cache_Frontend_Class extends Zend_Cache_Core
    36 {
    36 {
    37     /**
    37     /**
   198      * @param  array  $parameters Method parameters
   198      * @param  array  $parameters Method parameters
   199      * @return mixed Result
   199      * @return mixed Result
   200      */
   200      */
   201     public function __call($name, $parameters)
   201     public function __call($name, $parameters)
   202     {
   202     {
       
   203         $callback = array($this->_cachedEntity, $name);
       
   204 
       
   205         if (!is_callable($callback, false)) {
       
   206             Zend_Cache::throwException('Invalid callback');
       
   207         }
       
   208 
   203         $cacheBool1 = $this->_specificOptions['cache_by_default'];
   209         $cacheBool1 = $this->_specificOptions['cache_by_default'];
   204         $cacheBool2 = in_array($name, $this->_specificOptions['cached_methods']);
   210         $cacheBool2 = in_array($name, $this->_specificOptions['cached_methods']);
   205         $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_methods']);
   211         $cacheBool3 = in_array($name, $this->_specificOptions['non_cached_methods']);
   206         $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
   212         $cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
   207         if (!$cache) {
   213         if (!$cache) {
   208             // We do not have not cache
   214             // We do not have not cache
   209             return call_user_func_array(array($this->_cachedEntity, $name), $parameters);
   215             return call_user_func_array($callback, $parameters);
   210         }
   216         }
   211 
   217 
   212         $id = $this->_makeId($name, $parameters);
   218         $id = $this->_makeId($name, $parameters);
   213         if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1]) ) {
   219         if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1]) ) {
   214             // A cache is available
   220             // A cache is available
   218             // A cache is not available (or not valid for this frontend)
   224             // A cache is not available (or not valid for this frontend)
   219             ob_start();
   225             ob_start();
   220             ob_implicit_flush(false);
   226             ob_implicit_flush(false);
   221 
   227 
   222             try {
   228             try {
   223                 $return = call_user_func_array(array($this->_cachedEntity, $name), $parameters);
   229                 $return = call_user_func_array($callback, $parameters);
   224                 $output = ob_get_clean();
   230                 $output = ob_get_clean();
   225                 $data = array($output, $return);
   231                 $data = array($output, $return);
   226                 $this->save($data, $id, $this->_tags, $this->_specificLifetime, $this->_priority);
   232                 $this->save($data, $id, $this->_tags, $this->_specificLifetime, $this->_priority);
   227             } catch (Exception $e) {
   233             } catch (Exception $e) {
   228                 ob_end_clean();
   234                 ob_end_clean();