Apache Zeta Components Manual :: File Source for catchall.php
Source for file catchall.php
Documentation is available at catchall.php
* File containing the ezcMvcCatchAllRoute 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//
* Router class that acts like a catch all for /.../... type routes.
* The routes are matched against the uri property of the request object.
* @version //autogentag//
* If url has no controller to match, use this as default.
* If url has no action to match, use this as default.
* Only allow to catch routes that match at least this prefix.
private $prefix =
array();
* Construct a CatchAll Route
* @param string $defaultController
* @param string $defaultAction
public function __construct( $defaultController =
'index', $defaultAction =
'index' )
$this->action =
$defaultAction;
* Returns the request information that the matches() method will match the
* @param ezcMvcRequest $request
* Returns routing information if the route matched, or null in case the
* @param ezcMvcRequest $request Request to test.
* @return null|ezcMvcRoutingInformation
public function matches( ezcMvcRequest $request )
foreach ( $requestParts as $part )
// ignore, as it's the bit before the first /
$actionMethod =
call_user_func( array( $controllerName, 'createActionMethodName' ), $this->action );
$request->variables =
array_merge( $request->variables, $params );
* Create the param name from the indexed parameter
$paramName =
'param' .
$index;
* Create the controller name from the matched name
$controllerName =
$this->controller .
'Controller';
* Check if the prefix matches.
for ( $i =
0; $i <
count( $this->prefix ); $i++
)
if ( !isset
( $parts[$i] ) ||
$parts[$i] !==
$this->prefix[$i] )
* Adds a prefix to the route.
public function prefix( $prefix )
$this->prefix =
explode( '/', $prefix );