本文整理汇总了PHP中Zend_Controller_Dispatcher_Interface::isDispatchable方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Dispatcher_Interface::isDispatchable方法的具体用法?PHP Zend_Controller_Dispatcher_Interface::isDispatchable怎么用?PHP Zend_Controller_Dispatcher_Interface::isDispatchable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Dispatcher_Interface
的用法示例。
在下文中一共展示了Zend_Controller_Dispatcher_Interface::isDispatchable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: route
public function route(Zend_Controller_Dispatcher_Interface $dispatcher)
{
/**
* @todo Replace with Zend_Request object
*/
$path = $_SERVER['REQUEST_URI'];
if (strstr($path, '?')) {
$path = substr($path, 0, strpos($path, '?'));
}
/**
* Find the matching route
*/
foreach ($this->_routes as $route) {
if ($params = $route->match($path)) {
$controller = $params['controller'];
$action = $params['action'];
break;
}
}
$actionObj = new Zend_Controller_Dispatcher_Token($controller, $action, $params);
if (!$dispatcher->isDispatchable($actionObj)) {
throw new Zend_Controller_Router_Exception('Request could not be mapped to a route.');
} else {
return $actionObj;
}
}
示例2: route
public function route(Zend_Controller_Dispatcher_Interface $dispatcher)
{
/**
* @todo Replace with Zend_Request object
*/
$path = $_SERVER['REQUEST_URI'];
if (strstr($path, '?')) {
$path = substr($path, 0, strpos($path, '?'));
}
$path = explode('/', trim($path, '/'));
/**
* The controller is always the first piece of the URI, and
* the action is always the second:
*
* http://zend.com/controller-name/action-name/
*/
$controller = $path[0];
$action = isset($path[1]) ? $path[1] : null;
/**
* If no controller has been set, IndexController::index()
* will be used.
*/
if (!strlen($controller)) {
$controller = 'index';
$action = 'index';
}
/**
* Any optional parameters after the action are stored in
* an array of key/value pairs:
*
* http://www.zend.com/controller-name/action-name/param-1/3/param-2/7
*
* $params = array(2) {
* ["param-1"]=> string(1) "3"
* ["param-2"]=> string(1) "7"
* }
*/
$params = array();
for ($i = 2; $i < sizeof($path); $i = $i + 2) {
$params[$path[$i]] = isset($path[$i + 1]) ? $path[$i + 1] : null;
}
$actionObj = new Zend_Controller_Dispatcher_Token($controller, $action, $params);
if (!$dispatcher->isDispatchable($actionObj)) {
/**
* @todo error handling for 404's
*/
throw new Zend_Controller_Router_Exception('Request could not be mapped to a route.');
} else {
return $actionObj;
}
}
示例3: route
public function route(Zend_Controller_Dispatcher_Interface $dispatcher)
{
/**
* @todo Replace with Zend_Request object
*/
$path = $_SERVER['REQUEST_URI'];
if (strstr($path, '?')) {
$path = substr($path, 0, strpos($path, '?'));
}
// Remove RewriteBase
if (strlen($this->_rewriteBase) > 0 && strpos($path, $this->_rewriteBase) === 0) {
$path = substr($path, strlen($this->_rewriteBase));
}
/**
* Find the matching route
*/
$controller = 'index';
$action = 'noRoute';
foreach (array_reverse($this->_routes) as $route) {
if ($params = $route->match($path)) {
$controller = $params['controller'];
$action = $params['action'];
$this->_currentRoute = $route;
break;
}
}
$actionObj = new Zend_Controller_Dispatcher_Token($controller, $action, $params);
if (!$dispatcher->isDispatchable($actionObj)) {
throw new Zend_Controller_Router_Exception('Request could not be mapped to a route.');
} else {
return $actionObj;
}
}
示例4: route
public function route(Zend_Controller_Dispatcher_Interface $dispatcher, Zend_Uri_Http $url)
{
$params = false;
foreach ($this->routes as $route) {
$params = $route->isMatch($url);
if ($params !== false) {
break;
}
}
if ($params) {
$controller = 'index';
$action = 'index';
if (isset($params['controller']) && strlen($params['controller'])) {
$controller = $params['controller'];
if (isset($params['action'])) {
$action = $params['action'];
}
}
unset($params['controller'], $params['action']);
$token = new Zend_Controller_Dispatcher_Token($controller, $action, $params);
if ($dispatcher->isDispatchable($token)) {
return $token;
} else {
throw new Zend_Controller_Router_Exception('Request could not be mapped to a dispatchable route.');
}
} else {
throw new Zend_Controller_Router_Exception('Request could not be mapped to a route.');
}
}