Stash::_api_static_call PHP Method

_api_static_call() private method

API: call a Stash method statically (DEPRECATED, PHP <5.6 only)
private _api_static_call ( string $method, mixed $params, string $type = 'variable', string $scope = 'user', string $value = NULL ) : void
$method string
$params mixed variable name or an array of parameters
$type string
$scope string
$value string
return void
    private function _api_static_call($method, $params, $type = 'variable', $scope = 'user', $value = NULL)
    {
        // make sure we have a Template object to work with, in case Stash is being invoked outside of a template
        if (!class_exists('EE_Template')) {
            self::_load_EE_TMPL();
        }
        // make a copy of the current tagparams and tagdata for later
        $original_tagparams = array();
        $original_tagdata = FALSE;
        if (isset($this->EE->TMPL->tagparams)) {
            $original_tagparams = $this->EE->TMPL->tagparams;
        }
        if (isset($this->EE->TMPL->tagdata)) {
            $original_tagdata = $this->EE->TMPL->tagdata;
        }
        // make sure we have a slate to work with
        $this->EE->TMPL->tagparams = array();
        $this->EE->TMPL->tagdata = FALSE;
        if (is_array($params)) {
            $this->EE->TMPL->tagparams = $params;
        } else {
            $this->EE->TMPL->tagparams['name'] = $params;
            $this->EE->TMPL->tagparams['type'] = $type;
            $this->EE->TMPL->tagparams['scope'] = $scope;
        }
        if (!is_null($value)) {
            $this->EE->TMPL->tagdata = $value;
        }
        // as this function is called statically, we need to get a Stash object instance and run the requested method
        $self = new self();
        $result = $self->{$method}();
        // restore original template params and tagdata
        $this->EE->TMPL->tagparams = $original_tagparams;
        $this->EE->TMPL->tagdata = $original_tagdata;
        return $result;
    }