Habari\Plugins::theme PHP Method

theme() public static method

Call to execute a theme function
public static theme ( string $hookname, mixed $param ) : mixed
$hookname string The name of the filter to execute
$param mixed The value to filter
return mixed The filtered value
    public static function theme($hookname, $param)
    {
        $filter_args = func_get_args();
        $hookname = array_shift($filter_args);
        $filtersets = array();
        if (!isset(self::$hooks['theme'][$hookname])) {
            if (substr($hookname, -6) != '_empty') {
                array_unshift($filter_args, $hookname . '_empty');
                return call_user_func_array(Method::create('\\Habari\\Plugins', 'theme'), $filter_args);
            }
            return array();
        }
        $return = array();
        foreach (self::$hooks['theme'][$hookname] as $priority) {
            foreach ($priority as $filter) {
                // $filter is an array of object reference and method name
                $callargs = $filter_args;
                if (is_array($filter)) {
                    if (is_string($filter[0])) {
                        $module = $filter[0];
                    } else {
                        $module = get_class($filter[0]);
                        // @todo Make sure this doesn't break after the namespace update
                        if ($filter[0] instanceof Theme && $module != get_class($callargs[0])) {
                            continue;
                        }
                    }
                } else {
                    $module = $filter;
                }
                $return[$module] = call_user_func_array($filter, $callargs);
            }
        }
        if (count($return) == 0 && substr($hookname, -6) != '_empty') {
            array_unshift($filter_args, $hookname . '_empty');
            $result = call_user_func_array(Method::create('\\Habari\\Plugins', 'theme'), $filter_args);
        }
        array_unshift($filter_args, 'theme_call_' . $hookname, $return);
        $result = call_user_func_array(Method::create('\\Habari\\Plugins', 'filter'), $filter_args);
        return $result;
    }