Apache Zeta Components Manual :: File Source for configurable.php
Source for file configurable.php
Documentation is available at configurable.php
* File containing the ezcMvcConfigurableDispatcher class
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* This class implements an example dispatcher that can be configured through
* ezcMvcDispatcherConfiguration.
* @version //autogentag//
* Contains the configuration that determines which request parser, router,
* view handler and response writer are used.
* @var ezcMvcDispatcherConfiguration
* Creates a new ezcMvcConfigurableDispatcher
* @param ezcMvcDispatcherConfiguration $configuration
public function __construct( ezcMvcDispatcherConfiguration $configuration )
* Creates the controller by using the routing information and request data.
* @param ezcMvcRoutingInformation $routingInformation
* @param ezcMvcRequest $request
* @return ezcMvcController
protected function createController( ezcMvcRoutingInformation $routingInformation, ezcMvcRequest $request )
$controllerClass =
$routingInformation->controllerClass;
$controller =
new $controllerClass( $routingInformation->action, $request );
* Checks whether the number of redirects does not exceed the limit, and
* increases the $redirects count.
* @throws ezcMvcInfiniteLoopException when the number of redirects exceeds
* the limit (25 by default).
* Uses the configuration to fetch the request parser
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
* @return ezcMvcRequestParser
// create the request parser
* Uses the configuration to fetch the router
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
* @param ezcMvcRequest $request
protected function getRouter( ezcMvcRequest $request )
* Uses the router (through createController()) to fetch the controller
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
* @param ezcMvcRoutingInformation $routingInformation
* @param ezcMvcRequest $request
* @return ezcMvcController
protected function getController( ezcMvcRoutingInformation $routingInformation, ezcMvcRequest $request )
$controller->setRouter( $routingInformation->router );
* Uses the configuration to fetch the view handler
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
* @param ezcMvcRoutingInformation $routingInformation
* @param ezcMvcRequest $request
* @param ezcMvcResult $result
protected function getView( ezcMvcRoutingInformation $routingInformation, ezcMvcRequest $request, ezcMvcResult $result )
* Uses the configuration to fetch a fatal redirect request object
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
* @param ezcMvcRequest $request
* @param ezcMvcResult $result
$request->isFatal =
true;
* Uses the configuration to fetch the response writer
* @throws ezcMvcInvalidConfiguration when the returned object is of the wrong class
* @param ezcMvcRoutingInformation $routingInformation
* @param ezcMvcRequest $request
* @param ezcMvcResult $result
* @param ezcMvcResponse $response
* @return ezcMvcResponseWriter
protected function getResponseWriter( ezcMvcRoutingInformation $routingInformation, ezcMvcRequest $request, ezcMvcResult $result, ezcMvcResponse $response )
* Runs through the request, by using the configuration to obtain correct handlers.
// initialize infinite loop counter
$request =
$requestParser->createRequest();
// start of the request loop
// do the infinite loop check
// run pre-routing filters
// create the router from the configuration
// router creates routing information
$routingInformation =
$router->getRoutingInformation();
$request =
$filterResult->request;
$controller =
$this->getController( $routingInformation, $request );
$result =
$controller->createResult();
$request =
$result->request;
throw
new ezcMvcControllerException( "The action '{$routingInformation->action}' of controller '{
$routingInformation->controllerClass}' did not return an ezcMvcResult object.
" );
if ( $result->status !==
0 )
$response->status =
$result->status;
// want the view manager to use my filters
$view =
$this->getView( $routingInformation, $request, $result );
$response =
$view->createResponse();
// create the response writer
$responseWriter =
$this->getResponseWriter( $routingInformation, $request, $result, $response );
$responseWriter->handleResponse();