Stud.IP
6.0
|
A Controller is responsible for matching the unconsumed part of an URI to an action using the left over words as arguments for that action. The action is then mapped to method of the controller instance which is called with the just mentioned arguments. That method can send the #render_action, #render_template, #render_text, #render_nothing or #redirect method. Otherwise the #render_action is called with the current action as argument. If the action method sets instance variables during performing, they will be be used as attributes for the flexi-template opened by #render_action or #render_template. A controller's response's body is populated with the output of the #render_* methods. The action methods can add additional headers or change the status of that response.
The Dispatcher is used to map an incoming HTTP request to a Controller producing a response which is then rendered. To initialize an instance of class Dispatcher you have to give three configuration settings:
trails_root - the absolute file path to a directory containing the applications controllers, views etc. trails_uri - the URI to which routes to mapped Controller/Actions are appended
default_controller - the route to a controller, that is used if no controller is given, that is the route is equal to '/'
After instantiation of a dispatcher you have to call method #dispatch with the request uri to be mapped to a controller/action pair.
The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create action that sets $flash->set('notice', "Successfully created")
before redirecting to a display action that can then expose the flash to its template.
The Inflector class is a namespace for inflections methods.
This class represents a response returned by a controller that was asked to perform for a given request. A Response contains the body, status and additional headers which can be renderer back to the client.