Show:

Q_Dispatcher Class

This class lets you dispatch requests

Item Index

Methods

Properties

Methods

dispatch

(
  • [$uri=null]
  • [$check=array('accessible')]
)
Boolean static

Dispatches a URI for internal processing. Usually called by a front controller.

Parameters:

  • [$uri=null] Mixed optional

    You can pass a custom URI to dispatch. Otherwise, Qbix will attempt to route the requested URL, if any.

  • [$check=array('accessible')] Array optional

    Pass array() to skip checking whether the URI can be obtained as a result of routing some URL.

Returns:

Boolean:

errors

(
  • $exception
  • $module
  • [$partialResponse=null]
)
protected static

Parameters:

  • $exception Exception
  • $module String
  • [$partialResponse=null] String optional

forward

(
  • $uri
  • [$check=array('accessible')]
  • [$skip=null]
)
static

Forwards internally to a new URL, starting the dispatcher loop again

Parameters:

  • $uri Mixed

    The URI to forward to, either as a string, an array or a Q_Uri object.

  • [$check=array('accessible')] Mixed optional

    Pass array() here to skip checking whether the URI can be obtained as a result of routing some URL.

  • [$skip=null] Array optional

    Pass an array of events to avoid firing the next time through the dispatcher loop.

forward

(
  • $uri
)
static

Forwards internally to the URI "$AppName/notFound", starting the dispatcher loop again

Parameters:

  • $uri Mixed

    The URI to forward to, either as a string, an array or a Q_Uri object.

response

(
  • [$closeConnection=false]
  • [$flushBuffers=false]
)
static

Returns a response to the client.

Parameters:

  • [$closeConnection=false] Boolean optional

    Whether to flush all the buffers and send headers to close the connection

  • [$flushBuffers=false] Boolean optional

    Whether to flush the buffers

result

(
  • [$new_result=null]
  • [$overwrite=false]
)
static

Used to get/set the result of the dispatching

Parameters:

  • [$new_result=null] String optional

    Pass a string here to record a result of the dispatching.

  • [$overwrite=false] Boolean optional

    If a result is already set, doesn't override it unless you pass true here.

showErrors

() static

Stops processing the request and asks the dispatcher to jump straight to displaying the errors.

skip

() static

Call this to tell the dispatcher to skip firing a certain event coming up

uri

() Q_Uri static

Returns the URI that is currently being dispatched. You should usually use this instead of Q_Request::uri(), as they may be different after a call to Q_Dispatcher::forward()

Returns:

Properties

$errorsOccurred

Boolean protected static

$handlingErrors

Boolean protected static

$routed

Array public static

$servedResponse

Boolean public static

Whether a response was served since the last time dispatch started

$skip

Array protected static

$startedResponse

Boolean public static

Whether a response was started, since the beginning of the request

$uri

Q_Uri protected static

@startedDispatch

Boolean public static

Whether the dispatch method was called since the beginning of the request

Events

$module/errors

Event Payload:

  • exception Exception
  • module String
  • partialResponse String

Q/analytics

Gives the app a chance to gather analytics from the request.

Event Payload:

  • $routed Array

Q/dir

Event Payload:

  • filename String
  • routed_uri String

Q/errors

Event Payload:

  • exception Exception
  • module String
  • partialResponse String

Q/exception

Event Payload:

  • exception Exception

Q/file

Event Payload:

  • filename String
  • routed_uri String

Q/noModule

Occurs when no module was found during routing. The parameters are the routed array

Q/notFound

Occurs when no defined action was found during routing. The parameters are the routed array

Event Payload:

  • $routed Array

Q/objects

Gives the app a chance to fetch objects needed for handling the request.

Event Payload:

  • $routed Array

Q/prepare

Gives the app a chance to prepare for handling a request The parameters are the routed array

Event Payload:

  • $routed Array

Q/reroute

Gives the app a chance to reroute the request

Event Payload:

  • $routed Array

Q/response

Gives the app a chance to generate a response. You should not change the server state when handling this event.

Event Payload:

  • $routed Array

Q/validate

Gives the app a chance to validate the request and call Q_Response::addError() zero or more times. The parameters are the routed array

Event Payload:

  • $routed Array