The new Yii 1.1.4 contains numerous improvements. One that I wasn't clear on from the changelog was the line saying "automatic action parameter binding" for $_GET values. This is a very subtle way of saying that they've made it much easier to handle some of the 'grunt work' for actions that work with multiple $_GET variables.
http://www.yiiframework.com/doc/guide/basics.controller#action-parameter-binding
Quite simply pass in the name of the $_GET variables to the controller action method as parameters, including any default value you would like applied if they did not specify a value.
Easily looked over, but very nice addition to the framework!!
Thank you. I did not even know about it :D
ReplyDeleteAnything that keeps me from having:
ReplyDeleteif (isset($_GET['var']))
{
$var = $_GET['var'];
}
is a plus in my book.. :)
Yes, no kidding!! =)
ReplyDeleteAwesome! But it's not possible to use this in external CAction classes, is it? There is just the run()…
ReplyDeleteThat's a really interesting question and one I don't know the answer to. I'm definitely going to do some digging and find out ;)
ReplyDeleteNo, it won't work unless you're extending CInlineAction.
ReplyDeleteThe parameter binding happens in the CInlineAction::run() method. (See: http://code.google.com/p/yii/source/browse/tags/1.1.6/framework/web/actions/CInlineAction.php)
That said, you could duplicate the functionality within a CAction that you create by duplicating what's been done for the CInlineAction.
They've just added this ability in Yii 1.1.7 to have action parameter binding to the run method of a CAction!
ReplyDeletehttp://www.yiiframework.com/doc/guide/basics.controller#action-parameter-binding
Jep I saw it. Awesome.
ReplyDelete