codeigniter-filter icon indicating copy to clipboard operation
codeigniter-filter copied to clipboard

Allow having controller method params array in filters

Open edmundask opened this issue 12 years ago • 1 comments

Hi again,

I hope it's not getting annoying me poking around at your code but I found most of your stuff quite useful. Anyway, I've read your post about CodeIgniter controller filters and in one example you showed how to DRY out controllers by adding a separate method for fetching the resource (in your example get_resource()). Well, this doesn't work with your current code here on github, so I decided to take a look at it.

Turns out filters don't get the params array, therefore doing something like this $id = $params[0]; inside the filter isn't possible. I fixed the problem but I'm not sure if that's how you intended it to be.

I'll probably make my own controller filter support based on your code to better suit for my liking.

Cheers.

edmundask avatar Apr 07 '12 10:04 edmundask

I left the argument out by default so people didn't feel like they /had/ to add it. Perhaps I should include comments for it instead.

get_resource() can work via URI segments as well. I'm not entirely sure why my code is so disconnected from my thoughts in that example.

Hmm... let me think about this one and look over my code a bit. I haven't used CI in a bit so I need to revisit it some.

machuga avatar Apr 07 '12 15:04 machuga