Hi there!
I have a problem that I can't figure out.
I'm building a small framework (practice) and now I'm building the Validator library. everything works superb except when I trying to fix the "callback" rule. Callback rule is used when the dev need to use a rule that dosen't exists in the Validator lib..
Here's how I'm doing it.
In the controller:
$this->validator->check('req|callback:test', $_POST['module_name'], 'Module Name');
Validator Class:
public function check($rules, $input, $fieldname='') {
$rule = explode('|', $rules);
foreach ($rule as $r) {
$request = explode(":",$r,2);
$method = array_shift($request);
$parameter = $request;
array_unshift($parameter,$input);
array_push($parameter,$fieldname);
if (method_exists($this, $method)) {
call_user_func_array(array($this,$method), $parameter);
}
}
protected function callback($input, $key, $fieldname='') {
}
My problem is that, how can I use the "current" controller. For example, In this case I need to find:
UserController::test();
I can find the right method in $key but is the a simple way to figure out wich controller that's rolling?
I tried to use the url like:
$controller = ucfirst($uri->uri[1]).'Controller';
$controller::$key();
But that didn't work at all.. Any ideas?