Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JCacheControllerCallback
+ Graphe d'héritage de JCacheControllerCallback:
+ Graphe de collaboration de JCacheControllerCallback:

Liste de tous les membres

Fonctions membres publiques

 call ()
 get ($callback, $args=array(), $id=false, $wrkarounds=false, $woptions=array())
- Fonctions membres publiques inherited from JCacheController
 __construct ($options)
 __call ($name, $arguments)
 setCaching ($enabled)
 setLifeTime ($lt)
 get ($id, $group=null)
 store ($data, $id, $group=null, $wrkarounds=true)

Fonctions membres protégées

 _makeId ($callback, $args)

Additional Inherited Members

- Fonctions membres publiques statiques inherited from JCacheController
static getInstance ($type= 'output', $options=array())
static addIncludePath ($path= '')
- Attributs publics inherited from JCacheController
 $cache
 $options

Description détaillée

Définition à la ligne 19 du fichier callback.php.


Documentation des fonctions membres

JCacheControllerCallback::_makeId (   $callback,
  $args 
)
protected

Generate a callback cache id

Paramètres:
callback$callbackCallback to cache
array$argsArguments to the callback method to cache
Renvoie:
string MD5 Hash : function cache id
Depuis:
11.1

Définition à la ligne 194 du fichier callback.php.

{
if (is_array($callback) && is_object($callback[0]))
{
$vars = get_object_vars($callback[0]);
$vars[] = strtolower(get_class($callback[0]));
$callback[0] = $vars;
}
return md5(serialize(array($callback, $args)));
}
JCacheControllerCallback::call ( )

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
Renvoie:
mixed Result of the callback
Depuis:
11.1

Définition à la ligne 37 du fichier callback.php.

{
// Get callback and arguments
$args = func_get_args();
$callback = array_shift($args);
return $this->get($callback, $args);
}
JCacheControllerCallback::get (   $callback,
  $args = array(),
  $id = false,
  $wrkarounds = false,
  $woptions = array() 
)

Executes a cacheable callback if not found in cache else returns cached output and result

Paramètres:
mixed$callbackCallback or string shorthand for a callback
array$argsCallback arguments
string$idCache id
boolean$wrkaroundsTrue to use wrkarounds
array$woptionsWorkaround options
Renvoie:
mixed Result of the callback
Depuis:
11.1

Définition à la ligne 59 du fichier callback.php.

Références JFactory\getDocument(), JCache\getWorkarounds(), et JCache\setWorkarounds().

{
// Normalize callback
if (is_array($callback))
{
// 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);
}
else
{
// We have just a standard function -- do nothing
}
if (!$id)
{
// Generate an ID
$id = $this->_makeId($callback, $args);
}
$data = $this->cache->get($id);
$locktest = new stdClass;
$locktest->locked = null;
$locktest->locklooped = null;
if ($data === false)
{
$locktest = $this->cache->lock($id);
if ($locktest->locked == true && $locktest->locklooped == true)
{
$data = $this->cache->get($id);
}
}
$coptions = array();
if ($data !== false)
{
$cached = unserialize(trim($data));
$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);
}
}
else
{
if (!is_array($args))
{
$Args = !empty($args) ? array(&$args) : array();
}
else
{
$Args = &$args;
}
if ($locktest->locked == false)
{
$locktest = $this->cache->lock($id);
}
if (isset($woptions['modulemode']) && $woptions['modulemode'] == 1)
{
$document = JFactory::getDocument();
$coptions['modulemode'] = 1;
$coptions['headerbefore'] = $document->getHeadData();
}
else
{
$coptions['modulemode'] = 0;
}
ob_start();
ob_implicit_flush(false);
$result = call_user_func_array($callback, $Args);
$output = ob_get_contents();
ob_end_clean();
$cached = array();
$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['output'] = ($wrkarounds == false) ? $output : JCache::setWorkarounds($output, $coptions);
$cached['result'] = $result;
// Store the cache data
$this->cache->store(serialize($cached), $id);
if ($locktest->locked == true)
{
$this->cache->unlock($id);
}
}
echo $output;
return $result;
}

+ Voici le graphe d'appel pour cette fonction :


La documentation de cette classe a été générée à partir du fichier suivant :