You can't override find() in a Behavior. What you can do is create a
beforeFind() method. That will be called from the model's find().
However, it's expected that the Behavior should return an array (the
query data). You can return false, but then the model's find() will
return null, so I don't know how that would help.

Also, your parent::find() would be calling ModelBehavior. I don't
think that's likely what you want.

You can do some neat stuff by overriding find() in AppModel. See:
http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find

But I doubt that's what you're after.

What's this CacheBehavior supposed to do, anyway? And would it make
more sense if it was a component?

On Apr 12, 1:09 am, Mateo San Román <[email protected]> wrote:
> Hello,
>
> I'm currently implementing a Model Cache behavior. In order to work
> without changing other behaviors, components or helpers, I need to
> override the default Model::find function, to work like this:
>
> In behavior:
>    function find($conditions = null, $fields = array(), $order = null,
> $recursive = null) {
>       if (true /*$this->settings[$Model->alias]['auto']*/ )
>          return $this->cacheFind(&$Model, $type, $conditions, $fields,
> $order, $recursive);
>       return parent::find($type, $conditions, $fields, $order,
> $recursive);
>    }
>
> but it keeps calling Model::find before. I've tried doing this with
> the callbacks, with no luck.
>
> Thanks in advance.

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