Apache Zeta Components Manual :: File Source for view.php
Source for file view.php
Documentation is available at view.php
* File containing the ezcMvcView 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//
* The abstract view that you need to inherit from to supply your view zones.
* @version //autogentag//
* Holds the request object
* Holds the result object, that's the result of all the views.
* Creates the view object
* @param ezcMvcRequest $request
* @param ezcMvcResult $result
public function __construct( ezcMvcRequest $request, ezcMvcResult $result )
* The user-implemented that returns the zones.
* This method creates all the zones that are needed to render a view. A
* zone is an array of elements that implement a view handler. The view
* handlers do not have to be of the same type, as long as they implement
* the ezcMvcViewHandler interface.
* The $layout parameter can be used to determine whether a "page layout" should
* be added to the list of zones. This can be useful in case you're incorporating
* many different applications. The $layout parameter will be set to true automatically
* for the top level createZones() method, which can then chose to add zones from
* other views as well. The createZones() methods from those other views should
* have the $layout parameter set to false.
* @return array(ezcMvcViewHandler)
* Creates a controller from the set of routes.
* This method is run by the createResponse() method to obtain a rendered
* result from data from the controller. It uses the user implemented
* createZones() method from the inherited class to fetch the different
* zones of the view, and then loops over these zones in order. Each zone's
* results are made available to subsequent zones. Each zone will be
* processed by a view handler of the ezcMvcViewHandler class.
* @throws ezcMvcNoZonesException when there are no zones defined.
* @throws ezcBaseValueException when one of the returned zones was not
* actually an object implementing the ezcMvcViewHandler interface.
foreach ( $zones as $zone )
// Get the variables returned by the controller for the view
// Send it verbatim to the template processor
$zone->send( $propertyName, $propertyValue );
// Zones are additional templates that the final view should be built
// with. The main page layout is the last zone returned from
foreach ( $processed as $processedZone )
$zone->send( $processedZone->getName(), $processedZone->getResult() );
$zone->process( $zone ===
$lastZone );
return $zone->getResult();
* This method is called from the dispatched to create the rendered response from
* the controller's result.
* It calls the createResponseBody() to do the actual rendering. If any exception
* is thrown in any of the view handlers, this method catches it and returns that
* exception object to the dispatcher. The dispatcher must therefore check whether
* an exception object was returned. In case there was an exception, the dispatcher
* can take appropriate actions such as rendering a fatal error template.
* If everything goes well, this method returns an ezcMvcResponse object with the
* headers from the $result, and the response body from the processed views.
$result->generator, $result->cache, $result->cookies,
$result->content, $resultBody );