Hello,

I am implementing a datasource and I want to be able to invoke a
method on a model which uses the datasource such as:

$this->AModelUsingMyDatasource->my_method();

However it seems that all invocations on models are routed through the
query method.
I have implemented the following workaround in my datasource:

function query($method, $params, &$Model) {
        array_unshift($params, $Model);

        switch ($method) {
                case 'my_method':
                case 'another_method_of_mine':
                        return $this->dispatchMethod($method, $params);
                default:
                        trigger_error("Unkown method {$method}.", 
E_USER_WARNING);
                        return false;
        }
}

But to me this seems quite nasty... is there a better way to achieve
this?
The motivation is that i want to extend the find/read/create/delete
interface of the datasource since my datasource needs some additional
operations.
I would like to override the code which initially routes the
invocation to query(...) but cannot seem to find it in the CakePHP
codebase.

Cheers
-Simon

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to