本文整理汇总了PHP中Zend_Controller_Request_Abstract::clearParams方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Abstract::clearParams方法的具体用法?PHP Zend_Controller_Request_Abstract::clearParams怎么用?PHP Zend_Controller_Request_Abstract::clearParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Abstract
的用法示例。
在下文中一共展示了Zend_Controller_Request_Abstract::clearParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: routeShutdown
/**
* This action will decide what controllers will be called and in which order
*
* Note: this can change the expected dispatch behaviour!
*
* @param $request
* @return void
*/
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
//Check if the module is registered for HMVC
if (!$this->isActiveModule($request->getModuleName())) {
return;
}
//For some reason, unknown to me at this time, Zend_Controller_Request has lost all relevant info.
//Rebuild it from scratch.
$params = explode('/', trim($request->getPathInfo(), '/'));
if ($params[0] === $request->getModuleName()) {
//Unset the module if the same, not needed further
unset($params[0]);
}
$action = $request->getActionName();
$module = $request->getModuleName();
//Clear all params as new ones are on the way
$request->clearParams();
//Filter strings only
$names = array_filter($params, 'ctype_alpha');
//Filter digits only
$ids = array_filter($params, 'ctype_digit');
if (0 === count($names) && 0 === count($ids)) {
//We have nothing here to work with.. Assume default actions take over
return;
}
$dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
//Set some default params
$request->setParam('collection', false)->setParam('resource', true)->setParam('passthrough', true);
if (count($names) !== count($ids)) {
$ids = array_pad($ids, count($names), null);
$request->setParam('collection', true)->setParam('resource', false);
//Possible fix for crappy Zend_Rest_Route as the action is set to index
//Example: /rest/car should point to Hmvc/Controller/Car/"METHOD" to get a collection
if (!in_array($action, array('get', 'put', 'post', 'delete'))) {
$action = strtolower($request->getMethod());
}
}
//Combine all data
$params = array_combine($names, $ids);
$params['module'] = $module;
$params['action'] = $action;
$params['controller'] = $dispatcher->formatModuleName(current($names));
//Register with the request so the controllers can work with them
$request->setModuleName($module)->setActionName($action)->setParams($params);
$delimiter = $dispatcher->getPathDelimiter();
if (!Glitch_Registry::getConfig()->resources->hmvc->redispatch) {
$controller = $dispatcher->formatModuleName(implode($delimiter, $names));
$request->setControllerName($controller)->setParam('controller', $controller)->setDispatched(false)->setParam('passthrough', false);
return;
}
$nextController = '';
foreach ($names as $controller) {
//Collect the new controller string
$nextController .= $delimiter . $controller;
//Modify so it fits our structure and append to the controllers we want to handle
//We use formatModuleName as we already figured out our own structure
$this->_controllers[] = $dispatcher->formatModuleName(trim($nextController, $delimiter));
}
}