Stash::__call PHP Method

__call() public method

Shortcut to stash:get or stash:set
public __call ( string $name, array $arguments ) : void
$name string The method name being called or context if third tagpart
$arguments array The method call arguments
return void
    public function __call($name, $arguments)
    {
        /* Sample use
               ---------------------------------------------------------
               {exp:stash:foo}
               
               is equivalent to:
               
               {exp:stash:get name="foo"}
               ---------------------------------------------------------
               {exp:stash:foo}
               CONTENT
               {/exp:stash:foo}
               
               is equivalent to:
               
               {exp:stash:set name="foo"}
               CONTENT
               {/exp:stash:set}
               ---------------------------------------------------------
               {exp:stash:bar:foo}
               
               is equivalent to:
           
               {exp:stash:get name="bar:foo"}
               and
               {exp:stash:get context="bar" name="foo"}
               ---------------------------------------------------------
               {exp:stash:bar:foo}
               CONTENT
               {/exp:stash:bar:foo}
               
               is equivalent to:
               {exp:stash:set context="bar" name="foo"}
               CONTENT
               {/exp:stash:set}
               and
               {exp:stash:set name="bar:foo"}
               CONTENT
               {/exp:stash:set}
               --------------------------------------------------------- */
        switch ($name) {
            case 'unset':
                // make 'unset' - a reserved word - an alias of destroy()
                return call_user_func_array(array($this, 'destroy'), $arguments);
                break;
            case 'static':
                // make 'static' - a reserved word - an alias of static_cache()
                return call_user_func_array(array($this, 'static_cache'), $arguments);
                break;
            default:
                // if there is an extra tagpart, then we have a context and a name
                if (isset($this->EE->TMPL->tagparts[2])) {
                    $this->EE->TMPL->tagparams['context'] = $name;
                    $this->EE->TMPL->tagparams['name'] = $this->EE->TMPL->tagparts[2];
                } else {
                    $this->EE->TMPL->tagparams['name'] = $name;
                }
                return $this->EE->TMPL->tagdata ? $this->set() : $this->get();
        }
    }