public function runAction($action, array $vars = array())
    {
        $method = "{$action}Action";
        if (! method_exists($this,$method)) {
            throw new Exception("Controller method $method does not exist.");
        }

        $ro = new ReflectionObject( $this );
        $rm = $ro->getMethod($method);

        // Map vars to function arguments
        $parameters = $rm->getParameters();
        $arguments = array();
        foreach ($parameters as $param) {
            if (isset($vars[$param->getName()])) {
                $arguments[] = $vars[ $param->getName() ];
            }
        }

        return call_user_func_array( array($this,$method) , $arguments );
    }
public function runAction($action, array $vars = array())
    {
        $method = "{$action}Action";
        if (! method_exists($this,$method)) {
            throw new Exception("Controller method $method does not exist.");
        }

        $ro = new ReflectionObject( $this );
        $rm = $ro->getMethod($method);

        // Map vars to function arguments
        $parameters = $rm->getParameters();
        $arguments = array();
        foreach ($parameters as $param) {
            if (isset($vars[$param->getName()])) {
                $arguments[] = $vars[ $param->getName() ];
            }
        }

        return call_user_func_array( array($this,$method) , $arguments );
    }
public function runAction ( $ action , array $ vars = array ( ) ) { $ method = "{$action}Action" ; if ( ! method_exists ( $ this , $ method ) ) { throw new Exception ( "Controller method $method does not exist." ) ; } $ ro = new ReflectionObject ( $ this ) ; $ rm = $ ro -> getMethod ( $ method ) ; // Map vars to function arguments $ parameters = $ rm -> getParameters ( ) ; $ arguments = array ( ) ; foreach ( $ parameters as $ param ) { if ( isset ( $ vars [ $ param -> getName ( ) ] ) ) { $ arguments [ ] = $ vars [ $ param -> getName ( ) ] ; } } return call_user_func_array ( array ( $ this , $ method ) , $ arguments ) ; }
Run controller action

@param string $action Action name, the action name should not include "Action" as its suffix.
@param array $vars    Action method parameters, which will be applied to the method parameters by their names.
@return string        Return execution result in string format.
Run controller action