Habari\Theme::__call PHP Method

__call() public method

Allow plugins to provide additional theme actions, like a custom act_display_*()
public __call ( string $function, array $params )
$function string The method that was called.
$params array An array of parameters passed to the method
    public function __call($function, $params)
    {
        if (strpos($function, 'act_') === 0) {
            // The first parameter is an array, get it
            if (count($params) > 0) {
                list($user_filters) = $params;
            } else {
                $user_filters = array();
            }
            $action = substr($function, 4);
            Plugins::act('theme_action', $action, $this, $user_filters);
        } else {
            $purposed = 'output';
            if (preg_match('/^(.*)_(return|end|out)$/', $function, $matches)) {
                $purposed = $matches[2];
                $function = $matches[1];
            }
            array_unshift($params, $function, $this);
            $result = call_user_func_array(Method::create('\\Habari\\Plugins', 'theme'), $params);
            switch ($purposed) {
                case 'return':
                    return $result;
                case 'end':
                    return end($result);
                case 'out':
                    $output = implode('', (array) $result);
                    echo $output;
                    return $output;
                default:
                    $output = implode('', (array) $result);
                    return $output;
            }
        }
    }