[size="2"][font="arial, verdana, tahoma, sans-serif"][size="2"][font="arial, verdana, tahoma, sans-serif"][size="2"][size="2"]Hello everyone,
I am writing my first app with version 1.1.6 of Yii, after using version 1.1.3 and previous versions for the past year. It’s great to take advantage of all the awesome new features![/size][/size][/font]
One of the new features I am working with is parameter binding in my controller actions. What a great idea to add that!
However, I like to use the Yiic shell to test queries my models perform, etc., and because I set the default controller and default action, and the default action has a required parameter called $ss, the Console application is getting an HttpException with code 400, because it is missing the required parameter, and therefore is a bad request.
My question is, what is the best, most elegant way to determine at runtime what type of application I am running (e.g. instance of CWebApplication or CConsoleApplication)? I have tried calling:
get_class( Yii::app() )
from within the console, but surprisingly, it is a CWebApplication even there!
What I’d like to do ultimately is set the $ss parameter to default to null, then test to see if it is null within my controller action. Then, I want to test to find out what type of application is running - if it is a console application, I will just keep executing my code as normal, but if it is a web application and my required $_GET parameter, $ss, is missing or null, I will then throw an HttpException myself from within the action.
One final question - can anyone remind me when the request data and controller stuff was added to the console/shell? I remember reading about that in a past changelog, but I cannot seem to find that information now.
Thanks in advance!