-
Notifications
You must be signed in to change notification settings - Fork 3
Context object
Within CFlow, the Context object stores all information about events and makes object instances, such as controllers, available to executing tasks.
All object instances, except Event and Response instances are 'static', and thus cached by Context. These static objects therefore live as long as the Context object lives. Usually, you would create an instance of Context in onApplicationStart(), but basically it's up to you how you handle Context instances.
The Context exposes the following methods:
This is a default request handling implementation, that gathers variables in the url and form scopes, and dispatches the corresponding event. If there are target and event variables present in those scopes, then those variables define the event target and type. If they are not present, which happens for instance with the initial request to your application, the default target and default event are used. You can set these using setDefaultTarget() and setDefaultEvent().
The method returns the Response object that contains all generated content.
This method starts the event handling routine. Use this method if handleRequest() doesn't suit your needs.
Arguments:
- The target (string)
- The event type (string)
- Data that is available to the event (struct)
The method returns the Response object that contains all generated content.
Registers a Task to be executed for a given target and event, during a given phase. Use this method if you don't want to configure using the default XML dialect.
Arguments:
- The
Taskto be executed - The phase: 'start', 'before', 'after', 'end', or 'event'
- The target
- The event type