當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Controller_Request_Abstract::clearParams方法代碼示例

本文整理匯總了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));
     }
 }
開發者ID:nstapelbroek,項目名稱:Glitch_Lib,代碼行數:67,代碼來源:Hmvc.php


注:本文中的Zend_Controller_Request_Abstract::clearParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。