本文整理汇总了PHP中Zend_Controller_Request_Http::getModuleName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::getModuleName方法的具体用法?PHP Zend_Controller_Request_Http::getModuleName怎么用?PHP Zend_Controller_Request_Http::getModuleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::getModuleName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: preDispatch
/**
* Called before an action is dispatched by Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. The
* $action must be returned for the Zend_Controller_Dispatcher_Token to be dispatched.
* To abort the dispatch, return FALSE.
*
* @param Zend_Controller_Request_Http $action
* @return Zend_Controller_Dispatcher_Token|boolean
*/
public function preDispatch($action)
{
$module = $action->getModuleName();
$definition = null;
if (isset($this->config[$module])) {
$definition = $this->config[$module];
} else {
if (isset($this->config['master_layout'])) {
$definition = $this->config['master_layout'];
}
}
if ($definition != null && !$action->getParam('__ignorelayout')) {
$view = null;
$layoutName = $this->getViewNameFrom($definition, strtolower($action->getControllerName()), strtolower($action->getActionName()));
if ($layoutName) {
$view = new MasterView($layoutName, $this->config['layout_path']);
}
if ($view != null) {
Zend_Registry::set('MasterView', $view);
$baseView = Zend_Registry::get(NovemberApplication::$ZEND_VIEW);
$baseView->setMaster('MasterView');
}
}
return $action;
}
示例3: 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;
}
示例4: 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());
}
示例5: 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());
}
示例6: _getModuleOptions
/**
* Create requested module's options from the requested
* module's module.ini.
* Router resource can only be defined in application.ini.
*
* @return array
*/
private function _getModuleOptions()
{
$moduleName = $this->_request->getModuleName();
$moduleDir = $this->_moduleDir;
$modConfig = $moduleDir . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'module.ini';
$options = $this->_loadConfig($modConfig);
if (isset($options['resources']['router'])) {
throw new Exception('You can only set routes in application.ini');
}
return $options;
}
示例7: getPathParts
/**
* Parse more Zend_Controller_Request->getPathInfo()
* @param Zend_Controller_Request_Http $request
* @static
* @return boolean
*/
public static function getPathParts($request)
{
$pathParts = $request->getParams();
l($pathParts, __METHOD__ . ' $request->getParams()', Zend_Log::DEBUG);
$pathParts['host'] = (!empty($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']) . "/";
// SERVER_NAME?
$pathParts['module'] = $request->getModuleName();
/* $pathParts = array(
'host' => (!empty($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']) . "/", // SERVER_NAME?
'module' => $request->getModuleName(),
'controller' => $request->getParam('controller'), // AKA $request->getControllerName()
'action' => $request->getParam('action'), // AKA $request->getActionName()
'id' => $request->getParam('id'), // since 5/7/2009 (WAS @deprecated, moved into Zx_IndexController)
'page' => $request->getParam('page') // since 5/7/2009 (WAS @deprecated, moved into Zx_IndexController)
);
*/
// pre-router data @deprecated, use Zend_Controller_Router_Route for route rules!
/* $s = substr($_SERVER['REQUEST_URI'], 1, -1);
$a = explode('/', $s);
$pathParts['controller0'] = $a[0];
if (count($a) > 1) {
$pathParts['action0'] = $a[1];
}
*/
$prefix = self::getHttpPrefix();
$pathParts['path'] = $pathParts['controller'] . "/" . ($pathParts['action'] == 'index' ? '' : $pathParts['action'] . "/");
$pathParts['hostpath'] = $pathParts['host'] . $pathParts['path'];
$pathParts['url'] = $prefix . $pathParts['path'];
$pathParts['urlController'] = $prefix . $pathParts['controller'] . "/";
// controller only
Zend_Registry::set('path', $pathParts);
Zend_Registry::set('page', isset($pathParts['page']) ? $pathParts['page'] : 1);
// set to 1 if non-exists
#echo "DEBUG:<br><textarea rows=10 cols=100>" . print_r($pathParts, 1) . "</textarea><br>";die;
/* Array
(
[host] => il
[module] => default
[controller] => index
[action] => index
[id] =>
[url] => http://il/index/index/
)
*/
return $pathParts;
}
示例8: adCampaignBanner
/**
* @param Zend_Controller_Request_Http $request
* @return null|string
*/
public function adCampaignBanner(Zend_Controller_Request_Http $request)
{
// Get module name from request
$module = $request->getModuleName();
// Set or get campaign and content details in session, if any
$session = new Zend_Session_Namespace('homelet_global');
if ($request->getParam('utm_campaign') != '') {
$session->campaign = $request->getParam('utm_campaign');
}
if ($request->getParam('utm_content') != '') {
$session->content = $request->getParam('utm_content');
}
$this->campaign = $session->campaign;
$this->content = $session->content;
// Look up to see if there's a match between module, campaign and content.
if (isset($this->bannerMappings[$module][$this->campaign][$this->content])) {
// Pass the matching parameters to the partial view to display
$params = $this->bannerMappings[$module][$this->campaign][$this->content];
return $this->view->partial('partials/ad-campaign-banner.phtml', $params);
} else {
// No match, no banner
return null;
}
}
示例9: 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
//.........这里部分代码省略.........
示例10: 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;
}
示例11: getModuleName
/**
* Retrieve the module name
*
* @return string
*/
public function getModuleName()
{
return ucfirst(System_String::StrToLower(parent::getModuleName()));
}
示例12: 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}");
}
示例13: preDispatch
/**
* Called before an action is dispatched by Zend_Controller_Dispatcher.
*
* This callback allows for proxy or filter behavior. The
* $action must be returned for the Zend_Controller_Dispatcher_Token to be dispatched.
* To abort the dispatch, return FALSE.
*
* @param Zend_Controller_Request_Http $action
* @return Zend_Controller_Request_Http
*/
public function preDispatch($action)
{
/*@var $action Zend_Controller_Request_Http */
$controllerName = strtolower($action->getControllerName());
$actionName = strtolower($action->getActionName());
$moduleName = strtolower($action->getModuleName());
// Check for authorization.
$app = NovemberApplication::getInstance();
$currentUser = $app->getUser();
if ($currentUser->getRole() == User::ROLE_LOCKED) {
$action->setControllerName(ifset($this->config, 'login_controller', 'user'));
$action->setActionName(ifset($this->config, 'login_action', 'login'));
return $action;
}
// Get the restrictions for the current request (if any)
$conf = ifset($this->config, $moduleName);
$roles = '';
if (is_string($conf)) {
$roles = $conf;
} else {
if (is_array($conf)) {
// check for a default
$roles = ifset($conf, 'default_roles', '');
// If there's something in the controllername entry...
$controllerConf = ifset($conf, $controllerName, $roles);
if (is_array($controllerConf)) {
$roles = ifset($controllerConf, $actionName, $roles);
} else {
$roles = $controllerConf;
}
}
}
// Are there required roles to authenticate?
$loginRequired = false;
za()->log(__CLASS__ . ':' . __LINE__ . " - Authorizing " . $currentUser->getUsername() . " for roles {$roles}");
if ($roles != '') {
$loginRequired = true;
$roles = explode(',', $roles);
// If the user has any of the roles, let them in
foreach ($roles as $role) {
if ($currentUser->hasRole($role)) {
return $action;
}
}
}
// If we've got this far, then we should ask the DB if the current user has
// access to the current module and controller
// We're expecting user_access =>
// user_role
// OR array (controller => user_role)
$userAccess = ifset($conf, 'user_access');
if ($userAccess != null) {
$loginRequired = true;
// if it's a string, just get the access for the module
$accessService = za()->getService('AccessService');
// See if they have access to this module
$access = $accessService->getAccessList($currentUser->getUsername(), $moduleName);
if (count($access)) {
// okay, they have access, so we're all cool
return $action;
}
}
if ($loginRequired) {
$url = build_url($controllerName, $actionName, $action->getUserParams(), false, $moduleName);
$_SESSION[NovemberController::RETURN_URL] = $url;
// $action->setModuleName(ifset($this->config, 'login_module', 'default'));
$action->setControllerName($this->config['login_controller']);
$action->setActionName($this->config['login_action']);
}
return $action;
}
示例14: match
/**
* Match the request.
*
* @param Zend_Controller_Request_Http $request The request object.
*
* @return boolean
*/
public function match(Zend_Controller_Request_Http $request)
{
if (!$this->_beforeModuleMatch()) {
return false;
}
$this->fetchDefault();
$front = $this->getFront();
$path = trim($request->getPathInfo(), '/');
$module = null;
if ($path) {
$parts = explode('/', $path);
} else {
$parts = explode('/', $this->_getDefaultPath());
}
// get module name
if ($request->getModuleName()) {
$module = $request->getModuleName();
}
if (!$module) {
if (Mage::app()->getStore()->isAdmin()) {
return false;
}
}
// Does module match front name
$loadByPath = false;
if ($module != Mage::helper('link')->getFrontName()) {
// If not, check the table for a match on the path
if ($link = Mage::getModel('link/node')->loadByRequestPath($path)) {
$module = Mage::helper('link')->getFrontName();
$loadByPath = true;
}
}
// Translate frontName to module
$realModule = Mage::helper('link')->getModuleName();
$request->setRouteName($this->getRouteByFrontName($module));
// Get controller name
$controller = $front->getDefault('controller');
// Get action name
$action = $front->getDefault('action');
if ($loadByPath) {
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim(implode('/', $parts), '/'));
} else {
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim(implode('/', array_slice($parts, 1)), '/'));
}
// Checking if this place should be secure
$this->_checkShouldBeSecure($request, "/{$module}/{$controller}/{$action}");
$controllerClassName = $this->_validateControllerClassName($realModule, $controller);
if (!$controllerClassName) {
return false;
}
// Instantiate controller class
$controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
return false;
}
// Set values
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
$request->setControllerModule($realModule);
// Set parameters from pathinfo
for ($i = 1, $length = sizeof($parts); $i < $length; $i += 2) {
$request->setParam($parts[$i], isset($parts[$i + 1]) ? urldecode($parts[$i + 1]) : '');
}
// Dispatch action
$request->setDispatched(true);
$controllerInstance->dispatch($action);
return true;
}
示例15: canProcessRequest
/**
* Do basic validation for request to be cached
*
* @param Zend_Controller_Request_Http $request request
*
* @return bool
*/
public function canProcessRequest(Zend_Controller_Request_Http $request)
{
$res = $this->isAllowed();
$res = $res && $this->isEnabled();
$fullActionName = $request->getModuleName() . '_' . $request->getControllerName() . '_' . $request->getActionName();
if (!in_array($fullActionName, $this->_getAllowedActions())) {
$res = false;
}
if ($request->getParam('no_cache')) {
$res = false;
}
return $res;
}