本文整理汇总了PHP中Zend_Controller_Front::getDispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Front::getDispatcher方法的具体用法?PHP Zend_Controller_Front::getDispatcher怎么用?PHP Zend_Controller_Front::getDispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Front
的用法示例。
在下文中一共展示了Zend_Controller_Front::getDispatcher方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Prepares the route for mapping by splitting (exploding) it
* to a corresponding atomic parts. These parts are assigned
* a position which is later used for matching and preparing values.
*
* @param Zend_Controller_Front $front Front Controller object
* @param string $route Map used to match with later submitted URL path
* @param array $defaults Defaults for map variables with keys as variable names
* @param array $reqs Regular expression requirements for variables (keys as variable names)
* @param Zend_Translate $translator Translator to use for this instance
*/
public function __construct(Zend_Controller_Front $front, $route, $defaults = array(), $reqs = array(), Zend_Translate $translator = null, $locale = null)
{
$this->_front = $front;
$this->_dispatcher = $front->getDispatcher();
$this->_route = $route;
parent::__construct($route, $defaults, $reqs, $translator, $locale);
}
示例2: __construct
/**
* Constructor
*
* @param Zend_Controller_Front $front Front Controller object
* @param array $defaults Defaults for map variables with keys as variable names
* @param array $responders Modules or controllers to receive RESTful routes
*/
public function __construct(Zend_Controller_Front $front, array $defaults = array(), array $responders = array())
{
$this->_defaults = $defaults;
if ($responders) {
$this->_parseResponders($responders);
}
if (isset($front)) {
$this->_request = $front->getRequest();
$this->_dispatcher = $front->getDispatcher();
}
}
示例3: _translateSpec
/**
* Inflect based on provided vars
*
* Allowed variables are:
* - :moduleDir - current module directory
* - :module - current module name
* - :controller - current controller name
* - :action - current action name
* - :suffix - view script file suffix
*
* @param array $vars
* @return string
*/
protected function _translateSpec(array $vars = array())
{
$inflector = $this->getInflector();
$request = $this->getRequest();
$dispatcher = $this->_frontController->getDispatcher();
$module = $dispatcher->formatModuleName($request->getModuleName());
$controller = substr($dispatcher->formatControllerName($request->getControllerName()), 0, -10);
$action = $dispatcher->formatActionName($request->getActionName());
$params = compact('module', 'controller', 'action');
foreach ($vars as $key => $value) {
switch ($key) {
case 'module':
case 'controller':
case 'action':
case 'moduleDir':
case 'suffix':
$params[$key] = (string) $value;
break;
default:
break;
}
}
if (isset($params['suffix'])) {
$origSuffix = $this->getViewSuffix();
$this->setViewSuffix($params['suffix']);
}
if (isset($params['moduleDir'])) {
$origModuleDir = $this->_getModuleDir();
$this->_setModuleDir($params['moduleDir']);
}
$filtered = $inflector->filter($params);
if (isset($params['suffix'])) {
$this->setViewSuffix($origSuffix);
}
if (isset($params['moduleDir'])) {
$this->_setModuleDir($origModuleDir);
}
return $filtered;
}
示例4: match
/**
* Matches a user submitted request. Assigns and returns an array of variables
* on a successful match.
*
* If a request object is registered, it uses its setModuleName(),
* setControllerName(), and setActionName() accessors to set those values.
* Always returns the values as an array.
*
* @param Zend_Controller_Request_Http $request Request used to match against this routing ruleset
* @return array An array of assigned values or a false on a mismatch
*/
public function match($request)
{
if (!$request instanceof Zend_Controller_Request_Http) {
$request = $this->_front->getRequest();
}
$this->_request = $request;
$this->_setRequestKeys();
$path = $request->getPathInfo();
$values = array();
$params = array();
$path = trim($path, self::URI_DELIMITER);
if ($path != '') {
$path = explode(self::URI_DELIMITER, $path);
// Determine Module
$moduleName = $this->_defaults[$this->_moduleKey];
$dispatcher = $this->_front->getDispatcher();
if ($dispatcher && $dispatcher->isValidModule($path[0])) {
$moduleName = $path[0];
if ($this->_checkRestfulModule($moduleName)) {
$values[$this->_moduleKey] = array_shift($path);
$this->_moduleValid = true;
}
}
// Determine Controller
$controllerName = $this->_defaults[$this->_controllerKey];
if (count($path) && !empty($path[0])) {
if ($this->_checkRestfulController($moduleName, $path[0])) {
$controllerName = $path[0];
$values[$this->_controllerKey] = array_shift($path);
$values[$this->_actionKey] = 'get';
} else {
// If Controller in URI is not found to be a RESTful
// Controller, return false to fall back to other routes
return false;
}
}
//Store path count for method mapping
$pathElementCount = count($path);
// Check for leading "special get" URI's
$specialGetTarget = false;
if ($pathElementCount && array_search($path[0], array('index', 'new')) > -1) {
$specialGetTarget = array_shift($path);
} elseif ($pathElementCount && $path[$pathElementCount - 1] == 'edit') {
$specialGetTarget = 'edit';
$params['id'] = $path[$pathElementCount - 2];
} elseif ($pathElementCount == 1) {
$params['id'] = array_shift($path);
} elseif ($pathElementCount == 0 || $pathElementCount > 1) {
$specialGetTarget = 'index';
}
// Digest URI params
if ($numSegs = count($path)) {
for ($i = 0; $i < $numSegs; $i = $i + 2) {
$key = urldecode($path[$i]);
$val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null;
$params[$key] = $val;
}
}
// Determine Action
$requestMethod = strtolower($request->getMethod());
if ($requestMethod != 'get') {
if ($request->getParam('_method')) {
$values[$this->_actionKey] = strtolower($request->getParam('_method'));
} elseif ($request->getHeader('X-HTTP-Method-Override')) {
$values[$this->_actionKey] = strtolower($request->getHeader('X-HTTP-Method-Override'));
} else {
$values[$this->_actionKey] = $requestMethod;
}
// Map PUT and POST to actual create/update actions
// based on parameter count (posting to resource or collection)
switch ($values[$this->_actionKey]) {
case 'post':
if ($pathElementCount > 0) {
$values[$this->_actionKey] = 'put';
} else {
$values[$this->_actionKey] = 'post';
}
break;
case 'put':
$values[$this->_actionKey] = 'put';
break;
}
} elseif ($specialGetTarget) {
$values[$this->_actionKey] = $specialGetTarget;
}
}
$this->_values = $values + $params;
return $this->_values + $this->_defaults;
}
示例5: __construct
public function __construct(Zend_Controller_Front $frontController)
{
$this->dispatcher = $frontController->getDispatcher();
}
示例6: __construct
/**
* Constructor
*
* @param Zend_Controller_Front $front Front Controller object
* @param array $defaults Defaults for map variables with keys as variable names
* @param array $responders Modules or controllers to receive RESTful routes
*/
public function __construct(Zend_Controller_Front $front)
{
$this->_front = $front;
$this->_dispatcher = $front->getDispatcher();
$this->_defaults = array();
}