本文整理汇总了PHP中Zend_Controller_Request_Http::getActionName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::getActionName方法的具体用法?PHP Zend_Controller_Request_Http::getActionName怎么用?PHP Zend_Controller_Request_Http::getActionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::getActionName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetActionName
public function testSetGetActionName()
{
$this->_request->setActionName('foo');
$this->assertEquals('foo', $this->_request->getActionName());
$this->_request->setActionName('bar');
$this->assertEquals('bar', $this->_request->getActionName());
}
示例2: hasHtmlOutput
public function hasHtmlOutput()
{
// Only show toggle for individual answer display
if ($this->request->getActionName() !== 'answer') {
return false;
}
return true;
}
示例3: testShouldAllowAccessForCorrectRole
public function testShouldAllowAccessForCorrectRole()
{
$request = $this->request->setModuleName('admin')->setControllerName('index')->setActionName('index');
$this->acl->addResource('admin_index');
$this->acl->allow(Acl::ROLE_GUEST, 'admin_index');
$plugin = new Acl($this->acl);
$plugin->setRequest($this->request);
$plugin->preDispatch();
$this->assertEquals('admin', $this->request->getModuleName());
$this->assertEquals('index', $this->request->getControllerName());
$this->assertEquals('index', $this->request->getActionName());
}
示例4: isActive
/**
* Checks if site is active for the current request
*
* @param bool $checkSubs [optional] whether site should be considered
* active if a subsite is active, default is false
* @return bool
*/
public function isActive($checkSubs = false)
{
if (isset($this->uri)) {
// when uri is set, it is considered to be off-site
return false;
}
if (null == self::$_request) {
self::$_request = Zend_Controller_Front::getInstance()->getRequest();
}
$reqModule = self::$_request->getModuleName();
$reqController = self::$_request->getControllerName();
$reqAction = self::$_request->getActionName();
if ($this->module == $reqModule &&
$this->controller == $reqController &&
$this->action == $reqAction) {
return true;
}
if ($checkSubs && $this->hasSubSites()) {
foreach ($this->_subSites as $id => $subSite) {
if ($subSite->isActive(true)) {
return true;
}
}
}
return false;
}
示例5: testPostDispatchWithoutException
public function testPostDispatchWithoutException()
{
$this->request->setModuleName('foo')->setControllerName('bar')->setActionName('baz');
$this->plugin->postDispatch($this->request);
$this->assertEquals('baz', $this->request->getActionName());
$this->assertEquals('bar', $this->request->getControllerName());
$this->assertEquals('foo', $this->request->getModuleName());
}
示例6: testPreDispatchNonWhitelistedActionWithAuthenticatedSession
public function testPreDispatchNonWhitelistedActionWithAuthenticatedSession()
{
$this->request->setModuleName('default')->setControllerName('foo')->setActionName('home');
Zend_Auth::getInstance()->getStorage()->write(true);
$this->plugin->preDispatch($this->request);
$this->assertEquals('default', $this->request->getModuleName());
$this->assertEquals('foo', $this->request->getControllerName());
$this->assertEquals('home', $this->request->getActionName());
}
示例7: dispatchRequest
protected function dispatchRequest(Zend_Controller_Request_Http $request, X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
{
/* @var $view Zend_Controller_Action_Helper_ViewRenderer */
$view = $controller->getHelper('viewRenderer');
/* @var $layout Zend_Layout_Controller_Action_Helper_Layout */
$layout = $controller->getHelper('layout');
try {
$view->setNoRender(true);
$layout->disableLayout();
} catch (Exception $e) {
X_Debug::e("Layout or View not enabled: " . $e->getMessage());
}
$result = array();
$actionName = $request->getActionName();
$controllerName = $request->getControllerName();
$result['controller'] = $controllerName;
$result['action'] = $actionName;
$result['success'] = true;
$result['items'] = array();
/* @var $urlHelper Zend_Controller_Action_Helper_Url */
$urlHelper = $controller->getHelper('url');
$skipMethod = array('getCustom', 'getLinkParam', 'getLinkAction', 'getLinkController');
foreach ($items->getItems() as $itemId => $item) {
/* @var $item X_Page_Item_PItem */
$aItem = array();
$methods = get_class_methods(get_class($item));
foreach ($methods as $method) {
if (array_search($method, $skipMethod) !== false) {
continue;
}
if ($method == "getIcon") {
$aItem['icon'] = $request->getBaseUrl() . $item->getIcon();
} elseif (X_Env::startWith($method, 'get')) {
$aItem[lcfirst(substr($method, 3))] = $item->{$method}();
} elseif (X_Env::startWith($method, 'is')) {
$aItem[lcfirst(substr($method, 2))] = $item->{$method}();
}
}
$result['items'][] = $aItem;
}
/* @var $jsonHelper Zend_Controller_Action_Helper_Json */
$jsonHelper = $controller->getHelper('Json');
$jsonHelper->direct($result, true, false);
}
示例8: match
public function match(Zend_Controller_Request_Http $request)
{
$this->fetchDefault();
$front = $this->getFront();
$p = explode('/', trim($request->getPathInfo(), '/'));
// get module name
if ($request->getModuleName()) {
$module = $request->getModuleName();
} else {
$p = explode('/', trim($request->getPathInfo(), '/'));
$module = !empty($p[0]) ? $p[0] : $this->getFront()->getDefault('module');
}
if (!$module) {
return false;
}
$realModule = $this->getModuleByFrontName($module);
if (!$realModule) {
if ($moduleFrontName = array_search($module, $this->_modules)) {
$realModule = $module;
$module = $moduleFrontName;
} else {
return false;
}
}
if (!Mage::app()->isInstalled()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
exit;
}
if (Mage::app()->isInstalled() && !$request->isPost()) {
$shouldBeSecure = substr(Mage::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' || Mage::getStoreConfigFlag('web/secure/use_in_adminhtml') && substr(Mage::getStoreConfig('web/secure/base_url'), 0, 5) === 'https';
if ($shouldBeSecure && !Mage::app()->getStore()->isCurrentlySecure()) {
$url = Mage::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse();
exit;
}
}
// get controller name
if ($request->getControllerName()) {
$controller = $request->getControllerName();
} else {
$controller = !empty($p[1]) ? $p[1] : $front->getDefault('controller');
}
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$controllerFileName || !is_readable($controllerFileName)) {
$controller = 'index';
$action = 'noroute';
$controllerFileName = $this->getControllerFileName($realModule, $controller);
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
$controller = 'index';
$action = 'noroute';
$controllerFileName = $this->getControllerFileName($realModule, $controller);
}
// get action name
if (empty($action)) {
if ($request->getActionName()) {
$action = $request->getActionName();
} else {
$action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
}
}
// include controller file if needed
if (!class_exists($controllerClassName, false)) {
include $controllerFileName;
if (!class_exists($controllerClassName)) {
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Controller file was loaded but class does not exist'));
}
}
// instantiate controller class
$controllerInstance = new $controllerClassName($request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
return false;
}
// set values only after all the checks are done
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
// set parameters from pathinfo
for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
$request->setParam($p[$i], isset($p[$i + 1]) ? $p[$i + 1] : '');
}
// dispatch action
$request->setDispatched(true);
$controllerInstance->dispatch($action);
return true;
#$request->isDispatched();
}
示例9: logReroute
/**
* Log a message showing a reroute.
*
* @param Zend_Controller_Request_Http $request
* @param Zend_Config|array $rerouteTo where to reroute the request to
* @return void
*/
public static function logReroute(Zend_Controller_Request_Http $request, $rerouteTo, $reason)
{
if ($rerouteTo instanceof Zend_Config) {
$reroute = $rerouteTo->toArray();
} else {
$reroute = $rerouteTo;
}
self::log('Reroute from URI: ' . $request->getRequestUri() . ' (' . $request->getModuleName() . '/' . $request->getControllerName() . '/' . $request->getActionName() . '/' . ') to: ' . $reroute['moduleName'] . '/' . $reroute['controllerName'] . '/' . $reroute['actionName'] . " Reason: {$reason}");
}
示例10: match
public function match(Zend_Controller_Request_Http $request)
{
//checkings before even try to findout that current module should use this router
if (!$this->_beforeModuleMatch()) {
return false;
}
$this->fetchDefault();
$front = $this->getFront();
$p = explode('/', trim($request->getPathInfo(), '/'));
// get module name
if ($request->getModuleName()) {
$module = $request->getModuleName();
} else {
if (!empty($p[0])) {
$module = $p[0];
} else {
$module = $this->getFront()->getDefault('module');
$request->setAlias('rewrite_request_path', '');
}
}
if (!$module) {
if (App_Main::isAdmin()) {
$module = 'admin';
}
}
if (empty($module)) {
return false;
}
// Searching router args by module name from route using it as key
$modules = $this->getModuleByFrontName($module);
// If we did not found anything we searching exact this module name in array values
if ($modules === false) {
if ($moduleFrontName = $this->getModuleByName($module, $this->_modules)) {
$modules = array($module);
$module = $moduleFrontName;
}
}
if (empty($modules)) {
return false;
}
/**
* Going through modules to find appropriate controller
*/
$found = false;
foreach ($modules as $realModule) {
$request->setRouteName($this->getRouteByFrontName($module));
// get controller name
if ($request->getControllerName()) {
$controller = $request->getControllerName();
} else {
if (!empty($p[1])) {
$controller = $p[1];
} else {
$controller = $front->getDefault('controller');
$request->setAlias('rewrite_request_path', ltrim($request->getOriginalPathInfo(), '/'));
}
}
// get action name
if (empty($action)) {
if ($request->getActionName()) {
$action = $request->getActionName();
} else {
$action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
}
}
//checking if this place should be secure
$this->_checkShouldBeSecure($request, '/' . $module . '/' . $controller . '/' . $action);
$controllerClassName = $this->_validateControllerClassName($realModule, $controller);
if (!$controllerClassName) {
continue;
}
// instantiate controller class
$controllerInstance = new $controllerClassName($request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
continue;
}
$found = true;
break;
}
/**
* if we did not found any siutibul
*/
if (!$found) {
if ($this->_noRouteShouldBeApplied()) {
$controller = 'index';
$action = 'noroute';
$controllerClassName = $this->_validateControllerClassName($realModule, $controller);
if (!$controllerClassName) {
return false;
}
// instantiate controller class
$controllerInstance = new $controllerClassName($request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
return false;
}
} else {
return false;
}
}
// set values only after all the checks are done
//.........这里部分代码省略.........
示例11: parseHttpRequest
/**
* 根据Zend_Controller_Request_Http对象生成资源字符串
*
* @param Zend_Controller_Request_Http $request
* @return string
*/
public static function parseHttpRequest(Zend_Controller_Request_Http $request)
{
return self::parsePageMvc($request->getActionName(), $request->getControllerName(), $request->getModuleName());
}
示例12: _matchActionName
/**
* Match controller name
*
* @param Zend_Controller_Request_Http $request
* @param string $param
* @return string
*/
protected function _matchActionName(Zend_Controller_Request_Http $request, $param)
{
if (empty($action)) {
if ($request->getActionName()) {
$action = $request->getActionName();
} else {
$action = !empty($param) ? $param : $this->getFront()->getDefault('action');
}
} else {
$action = $param;
}
return $action;
}
示例13: getRequestProcessor
/**
* Get specific request processor based on request parameters.
*
* @param Zend_Controller_Request_Http $request
* @return Enterprise_PageCache_Model_Processor_Default
*/
public function getRequestProcessor(Zend_Controller_Request_Http $request)
{
$processor = false;
$configuration = Mage::getConfig()->getNode(self::XML_NODE_ALLOWED_CACHE);
if ($configuration) {
$configuration = $configuration->asArray();
}
$module = $request->getModuleName();
if (isset($configuration[$module])) {
$model = $configuration[$module];
$controller = $request->getControllerName();
if (is_array($configuration[$module]) && isset($configuration[$module][$controller])) {
$model = $configuration[$module][$controller];
$action = $request->getActionName();
if (is_array($configuration[$module][$controller]) && isset($configuration[$module][$controller][$action])) {
$model = $configuration[$module][$controller][$action];
}
}
if (is_string($model)) {
$processor = Mage::getModel($model);
}
}
return $processor;
}
示例14: match
public function match(Zend_Controller_Request_Http $request)
{
if (Mage::app()->getStore()->isAdmin()) {
return false;
}
$this->fetchDefault();
$front = $this->getFront();
$p = explode('/', trim($request->getPathInfo(), '/'));
// get module name
if ($request->getModuleName()) {
$module = $request->getModuleName();
} else {
if (!empty($p[0])) {
$module = $p[0];
} else {
$module = $this->getFront()->getDefault('module');
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, '');
}
}
if (!$module) {
return false;
}
$realModule = $this->getModuleByFrontName($module);
if (!$realModule) {
if ($moduleFrontName = array_search($module, $this->_modules)) {
$realModule = $module;
$module = $moduleFrontName;
} else {
return false;
}
}
$request->setRouteName($this->getRouteByFrontName($module));
// get controller name
if ($request->getControllerName()) {
$controller = $request->getControllerName();
} else {
if (!empty($p[1])) {
$controller = $p[1];
} else {
$controller = $front->getDefault('controller');
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/'));
}
}
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$this->validateControllerFileName($controllerFileName)) {
return false;
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
return false;
}
// get action name
if (empty($action)) {
if ($request->getActionName()) {
$action = $request->getActionName();
} else {
$action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
}
}
$this->_checkShouldBeSecure($request, '/' . $module . '/' . $controller . '/' . $action);
// include controller file if needed
if (!class_exists($controllerClassName, false)) {
if (!file_exists($controllerFileName)) {
return false;
}
include $controllerFileName;
if (!class_exists($controllerClassName, false)) {
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Controller file was loaded but class does not exist'));
}
}
// instantiate controller class
$controllerInstance = new $controllerClassName($request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
return false;
}
// set values only after all the checks are done
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
// set parameters from pathinfo
for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
$request->setParam($p[$i], isset($p[$i + 1]) ? $p[$i + 1] : '');
}
// dispatch action
$request->setDispatched(true);
$controllerInstance->dispatch($action);
return true;
#$request->isDispatched();
}
示例15: getRequestProcessor
/**
* Get specific request processor based on request parameters.
*
* @param Zend_Controller_Request_Http $request
* @return Enterprise_PageCache_Model_Processor_Default|false
*/
public function getRequestProcessor(Zend_Controller_Request_Http $request)
{
if ($this->_requestProcessor === null) {
$this->_requestProcessor = false;
$configuration = Mage::getConfig()->getNode(self::XML_NODE_ALLOWED_CACHE);
if ($configuration) {
$configuration = $configuration->asArray();
}
$module = $request->getModuleName();
$action = $request->getActionName();
if (strtolower($action) == self::NOT_FOUND_ACTION && isset($configuration['_no_route'])) {
$model = $configuration['_no_route'];
} elseif (isset($configuration[$module])) {
$model = $configuration[$module];
$controller = $request->getControllerName();
if (is_array($configuration[$module]) && isset($configuration[$module][$controller])) {
$model = $configuration[$module][$controller];
if (is_array($configuration[$module][$controller]) && isset($configuration[$module][$controller][$action])) {
$model = $configuration[$module][$controller][$action];
}
}
}
if (isset($model) && is_string($model)) {
$this->_requestProcessor = Mage::getModel($model);
}
}
return $this->_requestProcessor;
}