Zend Framework
3.0
|
Main application class for invoking applications. More...
Public Member Functions | |
__construct (ServiceManager $serviceManager, EventManagerInterface $events=null, RequestInterface $request=null, ResponseInterface $response=null) | |
Constructor. | |
getConfig () | |
Retrieve the application configuration. | |
bootstrap (array $listeners=[]) | |
Bootstrap the application. | |
getServiceManager () | |
Retrieve the service manager. | |
getRequest () | |
Get the request object. | |
getResponse () | |
Get the response object. | |
getMvcEvent () | |
Get the MVC event instance. | |
setEventManager (EventManagerInterface $eventManager) | |
Set the event manager instance. | |
getEventManager () | |
Retrieve the event manager. | |
run () | |
Run the application. | |
Static Public Member Functions | |
static | init ($configuration=[]) |
Static method for quick and easy initialization of the Application. | |
Public Attributes | |
const | ERROR_CONTROLLER_CANNOT_DISPATCH = 'error-controller-cannot-dispatch' |
const | ERROR_CONTROLLER_NOT_FOUND = 'error-controller-not-found' |
const | ERROR_CONTROLLER_INVALID = 'error-controller-invalid' |
const | ERROR_EXCEPTION = 'error-exception' |
const | ERROR_ROUTER_NO_MATCH = 'error-router-no-match' |
const | ERROR_MIDDLEWARE_CANNOT_DISPATCH = 'error-middleware-cannot-dispatch' |
Protected Member Functions | |
completeRequest (MvcEvent $event) | |
Complete the request. | |
Protected Attributes | |
$defaultListeners | |
$event | |
$events | |
$request | |
$response | |
$serviceManager = null | |
Main application class for invoking applications.
Expects the user will provide a configured ServiceManager, configured with the following services:
The most common workflow is: $services = new Zend($servicesConfig); $app = new Application($appConfig, $services); $app->bootstrap(); $response = $app->run(); $response->send();
bootstrap() opts in to the default route, dispatch, and view listeners, sets up the MvcEvent, and triggers the bootstrap event. This can be omitted if you wish to setup your own listeners and/or workflow; alternately, you can simply extend the class to override such behavior.
__construct | ( | ServiceManager | $serviceManager, |
EventManagerInterface | $events = null , |
||
RequestInterface | $request = null , |
||
ResponseInterface | $response = null |
||
) |
Constructor.
ServiceManager | $serviceManager | |
null | EventManagerInterface | $events | |
null | RequestInterface | $request | |
null | ResponseInterface | $response |
bootstrap | ( | array | $listeners = [] | ) |
Bootstrap the application.
Defines and binds the MvcEvent, and passes it the request, response, and router. Attaches the ViewManager as a listener. Triggers the bootstrap event.
array | $listeners | List of listeners to attach. |
|
protected |
Complete the request.
Triggers "render" and "finish" events, and returns response from event object.
MvcEvent | $event |
getConfig | ( | ) |
Retrieve the application configuration.
getEventManager | ( | ) |
Retrieve the event manager.
Lazy-loads an EventManager instance if none registered.
Implements EventsCapableInterface.
getMvcEvent | ( | ) |
Get the MVC event instance.
getRequest | ( | ) |
getResponse | ( | ) |
getServiceManager | ( | ) |
|
static |
Static method for quick and easy initialization of the Application.
If you use this init() method, you cannot specify a service with the name of 'ApplicationConfig' in your service manager config. This name is reserved to hold the array from application.config.php.
The following services can only be overridden from application.config.php:
All other services are configured after module loading, thus can be overridden by modules.
array | $configuration |
run | ( | ) |
Run the application.
route(MvcEvent) Routes the request, and sets the RouteMatch object in the event. dispatch(MvcEvent) Dispatches a request, using the discovered RouteMatch and provided request. dispatch.error(MvcEvent) On errors (controller not found, action not supported, etc.), populates the event with information about the error type, discovered controller, and controller class (if known). Typically, a handler should return a populated Response object that can be returned immediately.
Implements ApplicationInterface.
setEventManager | ( | EventManagerInterface | $eventManager | ) |
Set the event manager instance.
EventManagerInterface | $eventManager |
Implements EventManagerAwareInterface.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
const ERROR_CONTROLLER_CANNOT_DISPATCH = 'error-controller-cannot-dispatch' |
const ERROR_CONTROLLER_INVALID = 'error-controller-invalid' |
const ERROR_CONTROLLER_NOT_FOUND = 'error-controller-not-found' |
const ERROR_EXCEPTION = 'error-exception' |
const ERROR_MIDDLEWARE_CANNOT_DISPATCH = 'error-middleware-cannot-dispatch' |
const ERROR_ROUTER_NO_MATCH = 'error-router-no-match' |