I'm trying to call a controller and method pulled from the URI site.com/controller/method
Here is my current working code:
$__REQUEST__ = new URI_Request($_SERVER["REQUEST_URI"]);
$this->prepareController($__REQUEST__);
if($this->checkClass()) {
$this->controller = new $this->controller();
if($this->checkMethod($__REQUEST__)) {
$method = $__REQUEST__->getMethod();
$this->method = $method;
$this->controller->$method();
}
}
However, I want this line
$this->controller->$method();
To work as similarly to this
$this->controller = new $this->controller();
//achieves something like $this->controller = new IndexController();
//if the URL was something like site.com/index/test (/index/ gets manipulated)
i.e. something like
$this->controller->$this->method
I can see why this wouldn't work, however - is there a way to chain this or get it to reference the $method variable from the object characteristics rather than a stray variable?