Source for file callback.php
Documentation is available at callback.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Joomla! Cache callback type object
* @package Joomla.Platform
* Executes a cacheable callback if not found in cache else returns cached output and result
* Since arguments to this function are read with func_get_args you can pass any number of
* arguments to this method
* as long as the first argument passed is the callback definition.
* The callback definition can be in several forms:
* - Standard PHP Callback array see <http://php.net/callback> [recommended]
* - Function name as a string eg. 'foo' for function foo()
* - Static method name as a string eg. 'MyClass::myMethod' for method myMethod() of class MyClass
* @return mixed Result of the callback
// Get callback and arguments
return $this->get($callback, $args);
* Executes a cacheable callback if not found in cache else returns cached output and result
* @param mixed $callback Callback or string shorthand for a callback
* @param array $args Callback arguments
* @param string $id Cache id
* @param boolean $wrkarounds True to use wrkarounds
* @param array $woptions Workaround options
* @return mixed Result of the callback
public function get($callback, $args =
array(), $id =
false, $wrkarounds =
false, $woptions =
array())
// We have a standard php callback array -- do nothing
elseif (strstr($callback, '::'))
// This is shorthand for a static method callback classname::methodname
list
($class, $method) =
explode('::', $callback);
$callback =
array(trim($class), trim($method));
elseif (strstr($callback, '->'))
* This is a really not so smart way of doing this... we provide this for backward compatability but this
* WILL! disappear in a future version. If you are using this syntax change your code to use the standard
* PHP callback array syntax: <http://php.net/callback>
* We have to use some silly global notation to pull it off and this is very unreliable
list
($object_123456789, $method) =
explode('->', $callback);
global $
$object_123456789;
$callback =
array($
$object_123456789, $method);
// We have just a standard function -- do nothing
$id =
$this->_makeId($callback, $args);
$data =
$this->cache->get($id);
$locktest =
new stdClass;
$locktest->locked =
null;
$locktest->locklooped =
null;
$locktest =
$this->cache->lock($id);
if ($locktest->locked ==
true &&
$locktest->locklooped ==
true)
$data =
$this->cache->get($id);
$coptions['mergehead'] = isset
($woptions['mergehead']) ?
$woptions['mergehead'] :
0;
$output =
($wrkarounds ==
false) ?
$cached['output'] :
JCache::getWorkarounds($cached['output'], $coptions);
$result =
$cached['result'];
if ($locktest->locked ==
true)
$this->cache->unlock($id);
$Args =
!empty($args) ?
array(&$args) :
array();
if ($locktest->locked ==
false)
$locktest =
$this->cache->lock($id);
if (isset
($woptions['modulemode']) &&
$woptions['modulemode'] ==
1)
$coptions['modulemode'] =
1;
$coptions['headerbefore'] =
$document->getHeadData();
$coptions['modulemode'] =
0;
$coptions['nopathway'] = isset
($woptions['nopathway']) ?
$woptions['nopathway'] :
1;
$coptions['nohead'] = isset
($woptions['nohead']) ?
$woptions['nohead'] :
1;
$coptions['nomodules'] = isset
($woptions['nomodules']) ?
$woptions['nomodules'] :
1;
$cached['result'] =
$result;
if ($locktest->locked ==
true)
$this->cache->unlock($id);
* Generate a callback cache id
* @param callback $callback Callback to cache
* @param array $args Arguments to the callback method to cache
* @return string MD5 Hash : function cache id
protected function _makeId($callback, $args)
Documentation generated on Tue, 19 Nov 2013 14:55:00 +0100 by phpDocumentor 1.4.3