Jason
30 Mar 2010, 07:39 AM
Yo,
Anyone know how I can either do this or do something similar that achieves this?
I have a validation class. It contains a load of standard validation functions. This class also supports custom validation functions. This is where my problem is.
It works something like this.
Controller sends validation class the function name to use to validate a field.
Validation class creates a new instance of the controller class.
Validation class runs controller->validation_function()
Validation runs true or false.
The problem with this is that the validation class is creating an unneeded instance of the controller class.
I want to to do this.
$validation = new validation;
// Set rules
$validation->function() = $this->validation_function();
Any ideas on how to achieve this OR simply get the controller->function into the same scope as the validation class?
Anyone know how I can either do this or do something similar that achieves this?
I have a validation class. It contains a load of standard validation functions. This class also supports custom validation functions. This is where my problem is.
It works something like this.
Controller sends validation class the function name to use to validate a field.
Validation class creates a new instance of the controller class.
Validation class runs controller->validation_function()
Validation runs true or false.
The problem with this is that the validation class is creating an unneeded instance of the controller class.
I want to to do this.
$validation = new validation;
// Set rules
$validation->function() = $this->validation_function();
Any ideas on how to achieve this OR simply get the controller->function into the same scope as the validation class?