Gdn_Plugin::dispatch PHP Method

dispatch() public method

public dispatch ( $Sender, array $RequestArgs = [] ) : mixed
$Sender
$RequestArgs array
return mixed
    public function dispatch($Sender, $RequestArgs = array())
    {
        $this->Sender = $Sender;
        $Sender->Form = new Gdn_Form();
        $ControllerMethod = 'Controller_Index';
        if (is_array($RequestArgs) && sizeof($Sender->RequestArgs)) {
            list($MethodName) = $Sender->RequestArgs;
            // Account for suffix
            $MethodName = array_shift($Trash = explode('.', $MethodName));
            $TestControllerMethod = 'Controller_' . $MethodName;
            if (method_exists($this, $TestControllerMethod)) {
                $ControllerMethod = $TestControllerMethod;
                array_shift($RequestArgs);
            }
        }
        if (method_exists($this, $ControllerMethod)) {
            $Sender->Plugin = $this;
            return call_user_func(array($this, $ControllerMethod), $Sender, $RequestArgs);
        } else {
            $PluginName = get_class($this);
            throw NotFoundException("@{$PluginName}->{$ControllerMethod}()");
        }
    }