Skip to content

Extension hooks

Mark Croxton edited this page Apr 15, 2016 · 16 revisions

Stash defines the following extensions hooks for use in your extensions, or in Mustash plugins.

stash_delete

Executed when one or more variables are deleted.

Arguments

$data (array) — an associative array defining a Stash variable.

// -------------------------------------
// 'stash_delete' hook
// -------------------------------------
if ($this->EE->extensions->active_hook('stash_delete') === TRUE)
{
        $this->EE->extensions->call('stash_delete', array(
            'key_name'      => $key_name, // string/boolean
            'key_label'     => $key_label, // string/boolean
            'bundle_id'     => $bundle_id, // integer
            'session_id'    => $session_id, // string, may be 'site', '_global', 'user' or a session ID
            'site_id'       => $site_id // integer
        ));
}

stash_flush_cache

Executed when the entire cache for a site is cleared.

Arguments

$site_id (integer) — the id of the site that has been cleared.

// -------------------------------------
// 'stash_flush_cache' hook
// -------------------------------------
if ($this->EE->extensions->active_hook('stash_flush_cache') === TRUE)
{
    $this->EE->extensions->call('stash_flush_cache', $site_id);
}

stash_load_template_class

Allows substituting one's own template parsing class.

// -------------------------------------
// 'stash_load_template_class' hook
// -------------------------------------
if ($this->EE->extensions->active_hook('stash_load_template_class') === TRUE)
{
    $this->EE->TMPL = $this->EE->extensions->call('stash_load_template_class');
} 

stash_prune

Called when the Stash cache is periodically pruned of expired variables (whether there are variables to evict or not).

Arguments

$data (array) — an array of variables due to be evicted from the cache.

// -------------------------------------
// 'stash_prune' hook
// -------------------------------------
if ($this->EE->extensions->active_hook('stash_prune') === TRUE)
{
    $this->EE->extensions->call('stash_prune', $query->result_array());
}
Clone this wiki locally