I am building a wordpress plugin in some MVC style and i have setup almost every thing but when using call_user_func to call the request action class, I am not able to use the $this with the requested class.
Here is my code so far...
    class Action{
    protected $class;
    protected $method;
    protected $args = array();
    protected $template='settings/index';
    public function __construct() {
       $this->getRequest();
    }
    public function getRequest(){
        if(isset($_GET['c'])){
            $route = $_GET['c'];
            $parts = explode('/',$route);
            if(isset($parts[0]))
            $this->class = $parts[0];
            if(isset($parts[1]))
            $this->method = $parts[1];
            if(isset($parts[2]))
            $this->args[] = $parts[2];
            if(isset($parts[3]))
            $this->args[] = $parts[3];
        }
    }
    public function render(){
        extract($this->data);
        ob_start();
        require(LINKWAG_VIEW .DS. $this->template . P);
        $this->output = ob_get_contents();
        ob_end_clean();
        return $this;
    }
    public function output(){
        echo $this->output;
    }
}
class Grv extends Action{
    public function __construct() {
         parent::__construct();
        add_action('admin_menu', array($this,'setup'));
    }
    public function setup(){
         add_menu_page( 'LinkWag', 'LinkWag', 'manage_options', 'linkwag',array($this,'execute'), plugins_url( 'myplugin/images/icon.png' ), 6 ); 
    }
    public function  execute(){
        if($this->class){ 
           $this->controller = call_user_func_array(array($this->class,$this->method), $this->args);
        }
    }
}
The requested class goes here
class Settings extends Grv{
public function __construct() {
    //parent::__construct();
}
public function view($id=false){
    $this->template = 'settings/view'; // using $this here craetes a fatal error
   $this->render();
}
}
suppose i requested
admin.php?page=grv&c=settings/view/2
please tell me what i am doing wrong..
 
    