FriendsOfCake / crud

Production-grade rapid controller development with built in love for API and Search
https://crud.readthedocs.io/en/latest/
MIT License
375 stars 145 forks source link

Passing an agrument for findMethod (custom finder) #428

Closed TheMiller2015 closed 8 years ago

TheMiller2015 commented 8 years ago

Hello,

I start using CRUD. In an index-action I want to use a custom finder. So I tried to modify the query with the onBeforeFind, but this event isn't triggered (idk why). So I read through the docs and found findMethod(). My TableObject has a custom finder which only retrieves the records the user-x owns. Therefore, I pass the User-ID with $options while calling the finder manually. That works. But how do I pass the User-ID via the CRUDs findMethod()? I don't want to use the Auth-Component within the TableObject and "hardcode" the origin of the user-id. I hope, you understand what I mean. If there is no possibility to pass an argument for findMethod - would this be an idea for improvement in the upcoming versions?

Thanks

ADmad commented 8 years ago

Index action triggers "beforePaginate" event not "beforeFind" so use that to modify the query. The "findMethod" option doesn't support extra options.

jippi commented 8 years ago

findMethod is just quick way to change custom finder, relic from cake 2.x - today beforePaginate / beforeFind seems more sane to use imo

TheMiller2015 commented 8 years ago

Thank you all for your answers. Will the beforePaginate triggered even when my index method dorsn't call paginated? Will this be right right way nevertheless?

irongomme commented 7 years ago

I'm agree with @TheMiller2015, it would be great to pass args to the findMethod !