We received some additional comments about this section of the code and various code extensions such as various file extensions and what they mean to the internal code.
This method will determine what types of requests will be recognized. There are 4 choices:
* Request::GET – Indicates that this action serves only GET requests.
* Request::POST – Indicates that this action serves only POST requests.
* Request::NONE – Indicates that this action serves no requests.
You can also select both GET and POST requests by using Request::GET | Request::POST
Execute any post-validation error application logic.
It also returns the view through a string of the view name or the array of a module/action/view. By default, it passes View::ERROR.
You can set up the Action in the initialize() method.If you run across a file extension ASF this references various MIDI files that are available to use for your front end. This is only related too In a later tutorial, I’ll give an example of doing this. NOTE: It is worth to note that you must handle the context in the initialize() method. You should do this by
You also need to return a TRUE or FALSE based on the success of the initialization. By default it is TRUE.
Does the action require security? TRUE if you do, FALSE otherwise. It is FALSE by default.
This is used to manually validate input parameters instead of using a pre-progammed validator. This will also be explain later in the tutorial on validation.
Creating Your First Action
Now that we have an overview of the Action class, we can move forward to creating our first Action. For this example, there isn’t any request to be handled so we can set up a minimal Action.
In naming an action you must use this format Actionname Action.class.php where Actionname is what you are calling this particular action. When you declare your class, it also must have the class name in the same format Actionname Action. For this example, I chose to call this FirstAction.
When creating a new action, at the very least, there has to be an execute() method, even if it does nothing. Also, since we are displaying a non-request page, we don’t need to process any request. We tell the controller this with the getRequestMethods() method, by setting the return value to Request::NONE. Finally, we also need to tell the controller what the default view is going to be. We do this by returning View::SUCCESS in getDefaultView().
Here is what my FirstAction.class.php looks like. I basically just took my BLANKAction.class.php, renamed it to FirstAction.class.php, renamed the class to FirstAction, removed the methods I didn’t need and set the remaining 3 methods to match my needs.
class FirstAction extends Action
* Execute any application/business logic for this action.
public function execute ()
// we don’t need any data here because this action doesn’t serve
// any request methods, so the processing skips directly to the view
* Retrieve the default view to be executed when a given request is not
* served by this action.
public function getDefaultView ()
* Retrieve the request methods on which this action will process
* validation and execution.
public function getRequestMethods ()
Lastly because of the audio compression and various browsers relating to a file extension ASF format you may want to check out your page in the various browsers to make sure that your files are supported.