本文整理汇总了PHP中Zend_Controller_Request_Http::setActionName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::setActionName方法的具体用法?PHP Zend_Controller_Request_Http::setActionName怎么用?PHP Zend_Controller_Request_Http::setActionName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::setActionName方法的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: preDispatch
/**
* @param Zend_Controller_Request_Http $request
*/
public function preDispatch($request)
{
// dont filter anything if a resident is logged in
$session = new Zend_Session_Namespace();
if ($session->currentResidentId) {
$session->currentResident = Table_Residents::getInstance()->find($session->currentResidentId)->current();
return;
}
// allow index and session controller to all
if ($request->getControllerName() == 'index' || $request->getControllerName() == 'session') {
return;
}
// Authenticate direct requests for non-html stuff
if ($request->getParam('format') !== "html") {
// The requestor provided a username
if (isset($_SERVER['PHP_AUTH_USER'])) {
$resident = Table_Residents::getInstance()->findResidentByEmailAndPasswordhash($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
if ($resident) {
$session->currentResidentId = $resident->getId();
$session->currentResident = $resident;
return;
}
}
header('WWW-Authenticate: Basic realm="WG-Organizer"');
header('HTTP/1.0 401 Unauthorized');
die;
}
// else redirect to frontpage
$request->setControllerName('index');
$request->setActionName('index');
}
示例3: preDispatch
/**
* @param Zend_Controller_Request_Http $request
*/
public function preDispatch($request)
{
if ($request->getControllerName() == 'setup' || $request->getControllerName() == 'error') {
// allow all setup actions
// and all error actions
return;
} else {
// redirect other to setup install
$request->setControllerName('setup');
$request->setActionName('install');
}
}
示例4: testPreDispatch
/**
*/
public function testPreDispatch()
{
$this->acl->addRole('guest');
$request = new Zend_Controller_Request_Http();
$request->setModuleName('1');
$request->setControllerName('2');
$request->setActionName('3');
$this->object->preDispatch($request);
self::assertEquals('default', $request->getModuleName());
self::assertEquals('error', $request->getControllerName());
self::assertEquals('denied', $request->getActionName());
}
示例5: match
/**
* Match the request
*
* @param Zend_Controller_Request_Http $request
* @return boolean
*/
public function match(Zend_Controller_Request_Http $request)
{
//checking before even try to find out that current module
//should use this router
if (!$this->_beforeModuleMatch()) {
return false;
}
$front = $this->getFront();
$path = trim($request->getPathInfo(), '/');
$p = explode('/', $path);
if (count($p) == 0 || !$this->_pluarizeName($p[0])) {
return false;
} else {
$module = $this->_pluarizeName($p[0]);
$modules = $this->getModuleByFrontName($module);
if ($modules === false) {
return false;
}
// checks after we found out that this router should be used for current module
if (!$this->_afterModuleMatch()) {
return false;
}
// set values only after all the checks are done
$request->setModuleName($module);
$request->setControllerName('index');
$action = $this->_getActionFromPathInfo($p);
$request->setActionName($action);
$realModule = 'Zefir_Dealers';
$request->setControllerModule($realModule);
$request->setRouteName('dealers');
// dispatch action
$request->setDispatched(true);
/**
* Set params for the request
*/
if ($action == 'view') {
$request->setParam('dealer_code', $p[1]);
} else {
// set parameters from pathinfo
for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
$request->setParam($p[$i], isset($p[$i + 1]) ? urldecode($p[$i + 1]) : '');
}
}
// instantiate controller class and dispatch action
$controllerClassName = $this->_validateControllerClassName($realModule, 'index');
$controllerInstance = Mage::getControllerInstance($controllerClassName, $request, $front->getResponse());
$controllerInstance->dispatch($action);
return true;
}
}
示例6: match
/**
* Validate and Match Cms Page and modify request
*
* @param Zend_Controller_Request_Http $request
* @return bool
*/
public function match(Zend_Controller_Request_Http $request)
{
if (Mage::app()->getStore()->isAdmin()) {
return false;
}
$sellerAtttributeName = Mage::getConfig()->getNode('default/seller_page/attribute_name');
$seoDisplay = Mage::getConfig()->getNode('default/seller_page/seo_display');
if (empty($sellerAtttributeName)) {
//Seller attribute not configured
return false;
}
$pageId = $request->getPathInfo();
$param = explode('/', $pageId);
$seller = '';
if (count($param) > 1 and strtolower($param[1]) == $seoDisplay and !empty($param[2])) {
//Identify Seller
$sellerPage = $param[2];
if (strpos($sellerPage, '.') !== false) {
$sellerPage = urldecode(substr($sellerPage, 0, -5));
if ($sellerPage) {
$seller = str_replace('-', ' ', $sellerPage);
} else {
return false;
}
} else {
$seller = $sellerPage;
}
} else {
return false;
}
if ($seller) {
Mage::register('seller_company', $seller);
$realModule = 'Cybage_Marketplace';
$request->setModuleName('marketplace');
$request->setRouteName('marketplace');
$request->setControllerName('seller');
$request->setActionName('sellerinfo');
$request->setControllerModule($realModule);
$request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getRequestString(), '/'));
$file = Mage::getModuleDir('controllers', $realModule) . DS . 'SellerController.php';
include $file;
//compatibility with 1.3
$class = $realModule . '_SellerController';
$controllerInstance = new $class($request, $this->getFront()->getResponse());
$request->setDispatched(true);
$controllerInstance->dispatch('sellerinfo');
}
return true;
}
示例7: forwardShopby
protected function forwardShopby()
{
$reservedKey = Mage::getStoreConfig('amshopby/seo/key');
$realModule = 'Amasty_Shopby';
$this->request->setPathInfo($reservedKey);
$this->request->setModuleName('amshopby');
$this->request->setRouteName('amshopby');
$this->request->setControllerName('index');
$this->request->setActionName('index');
$this->request->setControllerModule($realModule);
$file = Mage::getModuleDir('controllers', $realModule) . DS . 'IndexController.php';
include $file;
//compatibility with 1.3
$class = $realModule . '_IndexController';
$controllerInstance = new $class($this->request, $this->getFront()->getResponse());
$this->request->setDispatched(true);
$controllerInstance->dispatch('index');
}
示例8: testAuthorization
public function testAuthorization()
{
$app = za();
za()->setUser(new GuestUser());
$pluginConf = $app->getConfig('plugins');
$conf = array('default' => array('user' => array('edit' => 'User,Admin', 'list' => 'Admin')), 'login_controller' => 'testcontroller', 'login_action' => 'testaction');
$plugin = new AuthorizationPlugin($conf);
$action = new Zend_Controller_Request_Http();
$action->setControllerName("user");
$action->setActionName('edit');
$action->setModuleName('default');
$plugin->preDispatch($action);
// Make sure it's redirected to the user / login controller
$this->assertEqual($action->getControllerName(), 'testcontroller');
$this->assertEqual($action->getActionName(), 'testaction');
// Now test that a user with role User is fine
$user = new User();
za()->setUser($user);
$user->role = 'User';
$action->setControllerName("user");
$action->setActionName('edit');
$plugin->preDispatch($action);
$this->assertEqual($action->getControllerName(), 'user');
$this->assertEqual($action->getActionName(), 'edit');
// Make sure they can't LIST
$action->setControllerName('user');
$action->setActionName('list');
$plugin->preDispatch($action);
$this->assertEqual($action->getControllerName(), 'testcontroller');
$this->assertEqual($action->getActionName(), 'testaction');
// Now make them an admin, make sure they can do both the above
$user->role = 'Admin';
$action->setControllerName("user");
$action->setActionName('edit');
$plugin->preDispatch($action);
$this->assertEqual($action->getControllerName(), 'user');
$this->assertEqual($action->getActionName(), 'edit');
// Make sure they can't LIST
$action->setControllerName('user');
$action->setActionName('list');
$plugin->preDispatch($action);
$this->assertEqual($action->getControllerName(), 'user');
$this->assertEqual($action->getActionName(), 'list');
}
示例9: preDispatch
/**
* @param Zend_Controller_Request_Http $request
*/
public function preDispatch($request)
{
// dont filter anything if a resident is logged in
$session = new Zend_Session_Namespace();
// Sets the resident id so the next if loads the user ;)
if ($request->getParam('appauth_key')) {
$session->currentResidentId = Table_Residents::getInstance()->findByAppAuthKey($request->getParam('appauth_key'));
}
if ($session->currentResidentId) {
$session->currentResident = Table_Residents::getInstance()->find($session->currentResidentId)->current();
return;
}
// allow index and session controller to all
if ($request->getControllerName() == 'index' || $request->getControllerName() == 'session') {
return;
}
// else redirect to frontpage
$request->setControllerName('index');
$request->setActionName('index');
}
示例10: testNamespacedModules
/**
* Test that classes are found in modules, using a prefix
*/
public function testNamespacedModules()
{
$this->_dispatcher->setControllerDirectory(array('default' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files', 'admin' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/Admin'));
$request = new Zend_Controller_Request_Http();
$request->setControllerName('foo');
$request->setActionName('bar');
$request->setParam('module', 'admin');
$this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files/Admin', $this->_dispatcher->getDispatchDirectory());
$response = new Zend_Controller_Response_Cli();
$this->_dispatcher->dispatch($request, $response);
$body = $this->_dispatcher->getResponse()->getBody();
$this->assertContains("Admin_Foo::bar action called", $body, $body);
}
示例11: match
public function match(Zend_Controller_Request_Http $request)
{
if (!Mage::app()->isInstalled()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
exit;
}
$frontName = Mage::getStoreConfig('blog/info/url_key');
$pathInfo = Mage::app()->getRequest()->getPathInfo();
if (in_array($pathInfo, array("/{$frontName}/", "/{$frontName}"))) {
$request->setModuleName('blog');
$request->setControllerName('index');
$request->setActionName('index');
return true;
}
$uri = str_replace("/{$frontName}/", "", strstr($pathInfo, "/{$frontName}/"));
if (!Mage::registry('request_path')) {
Mage::register('request_path', $uri);
}
$request->setAlias(self::REWRITE_REQUEST_PATH_ALIAS, "{$frontName}/" . $uri);
if (trim($uri, "/") == "taglist") {
$request->setControllerName('tag');
$request->setActionName('taglist');
return true;
}
if ($uri) {
$requestInfo = trim($uri);
$tmp = explode("_", $requestInfo);
if ($tmp[0] == "adminhtml") {
return true;
}
$urlData = $this->analyticUrl($requestInfo);
$request->setModuleName('blog');
if ($postId = $urlData->getPostId()) {
$request->setControllerName('post');
$request->setActionName('view');
$request->setParam('id', $postId);
$contentUrl = explode("/", $uri);
if (count($contentUrl) > 1) {
unset($contentUrl[count($contentUrl) - 1]);
Mage::app()->getRequest()->setParam('cat_id', $this->analyticUrl(implode('/', $contentUrl) . '.html')->getCategoryId());
}
return true;
} elseif ($tagId = $urlData->getTagId()) {
$request->setControllerName('tag');
$request->setActionName('view');
$request->setParam('tag_id', $tagId);
return true;
} elseif ($catId = $urlData->getCategoryId()) {
$request->setControllerName('category');
$request->setActionName('view');
$request->setParam('id', $catId);
return true;
} else {
$tmp = explode('/', $uri);
if (count($tmp) > 2 && count($tmp) % 2 == 1) {
return false;
}
$pathController = dirname(__FILE__) . DS . '..' . DS . 'controllers' . DS . ucfirst($tmp[0]) . 'Controller.php';
if (!file_exists($pathController)) {
return false;
}
require_once $pathController;
$request->setControllerName($tmp[0]);
$className = 'EM_Blog_' . ucfirst($tmp[0]) . 'Controller';
if (count($tmp) > 2) {
if (!method_exists($className, $tmp[1] . 'Action')) {
return false;
}
$request->setActionName($tmp[1]);
for ($i = 2; $i < count($tmp); $i++) {
if (!empty($tmp[$i + 1])) {
$request->setParam($tmp[$i], $tmp[$i + 1]);
}
}
} else {
if (count($tmp) == 2) {
if (!method_exists($className, $tmp[1] . 'Action')) {
return false;
}
$request->setActionName($tmp[1]);
} else {
$request->setActionName('index');
}
}
return true;
}
}
return false;
}
示例12: realpath
<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_ENV', 'development');
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../vendor/ZendFramework/library'), get_include_path())));
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();
// the needed resources
$frontController = $application->getBootstrap()->getResource('FrontController');
$view = $application->getBootstrap()->getResource('View');
// init request
$request = new Zend_Controller_Request_Http();
$request->setControllerName('partner-usage');
$request->setActionName('export-csv');
$fromDate = new Zend_Date();
$fromDate->setHour(0);
$fromDate->setMinute(0);
$fromDate->setSecond(0);
$fromDate->setDay(1);
$fromDate->addMonth(-1);
$request->setParam('from_date', $fromDate->getTimestamp());
// beginning of last month
$toDate = new Zend_Date($fromDate);
$toDate->addMonth(1);
$toDate->addSecond(-1);
$request->setParam('to_date', $toDate->getTimestamp());
// end of last month
// init response
$response = new Zend_Controller_Response_Cli();
// dispatch
示例13: testModuleSubdirControllerFound
public function testModuleSubdirControllerFound()
{
Zend_Controller_Front::getInstance()->addControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'controllers', 'foo');
$request = new Zend_Controller_Request_Http();
$request->setModuleName('foo');
$request->setControllerName('admin_index');
$request->setActionName('index');
$this->assertTrue($this->_dispatcher->isDispatchable($request), var_export($this->_dispatcher->getControllerDirectory(), 1));
$response = new Zend_Controller_Response_Cli();
$this->_dispatcher->dispatch($request, $response);
$body = $this->_dispatcher->getResponse()->getBody();
$this->assertContains("Foo_Admin_IndexController::indexAction() called", $body, $body);
}
示例14: notifyDispatchLoopStartup
/**
* Method gets called when the PreDispatcher's dispatchLoopStartup
* method gets called.
* This method is API only.
*
* @param Zend_Controller_Request_Abstract $request
*
* @packageprotected
*/
public function notifyDispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
if ($this->_preProcessRequest($request)) {
return;
}
if ($this->_isExtMultiRequest) {
return;
}
$config =& $this->_config;
$extDirectData = $request->getParam($config['extParameter'], null);
if ($extDirectData && is_string($extDirectData)) {
$decoded = Zend_Json::decode($extDirectData);
if (!Conjoon_Util_Array::isAssociative($decoded)) {
$this->_isExtMultiRequest = true;
$this->_isExtRequest = true;
for ($i = count($decoded) - 1; $i >= 0; $i--) {
$controller = strtolower(preg_replace('/([a-z])([A-Z])/', "\$1.\$2", $decoded[$i]['action']));
$action = strtolower(preg_replace('/([a-z])([A-Z])/', "\$1.\$2", $decoded[$i]['method']));
$req = new Zend_Controller_Request_Http();
$req->setActionName($action)->setControllerName($controller)->setModuleName($request->module);
$this->_requestStack[] = $req;
$this->_requestInfo[] = array('action' => $action, 'controller' => $controller, 'module' => $request->module);
$decoded[$i][$config['indexKey']] = count($this->_requestStack) - 1;
foreach ($config['additionalParams'] as $pKey => $pValue) {
$req->setParam($pKey, $pValue);
}
$this->_applyParams($req, $decoded[$i]);
}
foreach ($config['additionalParams'] as $pKey => $pValue) {
$request->setParam($pKey, $pValue);
}
if ($config['module']) {
$request->setModuleName($config['module']);
}
if ($config['controller']) {
$request->setControllerName($config['controller']);
}
if ($config['action']) {
$request->setActionName($config['action']);
}
$this->_copyParams();
$this->_copyHelper();
$this->_copyPlugins();
} else {
$this->_isExtRequest = true;
$this->_applyParams($request, $decoded);
}
}
$this->_processed = true;
}
示例15: matchUrl
public static function matchUrl(Zend_Controller_Request_Http $request)
{
if (AW_Kbase_Helper_Data::isModuleOutputDisabled() || !AW_Kbase_Helper_Data::getFrontendEnabled()) {
return false;
}
$urlKey = self::getModuleUrlKey();
$pathInfo = $request->getPathInfo();
$requestUri = $request->getRequestUri();
if ($request->getParam('___from_store')) {
$_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store'));
if ($_fromStore->getData()) {
$_oldUrlKey = self::getModuleUrlKeyFromConfig($_fromStore);
if (strpos($pathInfo, '/' . $_oldUrlKey) === 0 && $_oldUrlKey != $urlKey) {
$_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/');
$response = Mage::app()->getResponse();
$response->setRedirect($_newUrl);
$response->sendHeaders();
$request->setDispatched(true);
return true;
}
}
}
if (0 !== strpos($pathInfo, '/' . $urlKey . '/')) {
// if path does not begin with /kbase/
return false;
}
$pathInfo = substr($pathInfo, strlen($urlKey) + 2);
$request->setModuleName('kbase')->setControllerName('article');
if (!strlen($pathInfo)) {
$request->setActionName('index');
return AW_Kbase_Helper_Data::getFrontendEnabled() && self::cacheRewrite($request->getPathInfo(), 'kbase/article/index');
}
$urlKeySuffix = self::getUrlKeySuffix();
$isArticle = false;
if (!$urlKeySuffix) {
$_path = explode('/', $pathInfo);
$_aUrl = false;
if (count($_path) == 1) {
$_aUrl = $_path[0];
}
if (count($_path) == 2) {
$_aUrl = $_path[1];
}
if ($_aUrl) {
$_aUrl = urldecode($_aUrl);
$_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl);
if (!$_aId) {
$_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_aUrl, true);
}
if ($_aId) {
$isArticle = true;
}
}
}
/**
* Checking is customer comes from other store view
* having various article suffix id in comparison
* with current
*/
if ($request->getParam('___from_store') && !$isArticle) {
if (!isset($_fromStore)) {
$_fromStore = Mage::app()->getSafeStore($request->getParam('___from_store'));
}
if ($_fromStore->getData()) {
$_oldUrlSuffix = self::getUrlKeySuffixFromConfig($_fromStore);
if ($urlKeySuffix != $_oldUrlSuffix) {
$_path = explode('/', $pathInfo);
$_aUrl = false;
if (count($_path) == 1) {
$_aUrl = $_path[0];
}
if (count($_path) == 2) {
$_aUrl = $_path[1];
}
if ($_aUrl) {
$_articleUrlKey = substr($_aUrl, 0, strpos($_aUrl, $_oldUrlSuffix));
$_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey);
if (!$_aId) {
$_aId = Mage::getModel('kbase/article')->getResource()->getIdByUrlKey($_articleUrlKey, true);
}
if ($_aId) {
$_storeIds = Mage::getModel('kbase/article')->getResource()->getArticleStoreIds($_aId);
if (in_array(Mage::app()->getStore()->getId(), $_storeIds)) {
$_newUrl = self::secureUrl(Mage::getBaseUrl() . $urlKey . '/' . $_articleUrlKey . $urlKeySuffix);
$response = Mage::app()->getResponse();
$response->setRedirect($_newUrl);
$response->sendHeaders();
$request->setDispatched(true);
return true;
}
}
}
}
}
}
if ($urlKeySuffix && '/' != $urlKeySuffix && $urlKeySuffix == substr($pathInfo, -strlen($urlKeySuffix)) || $isArticle) {
$pathInfo = substr($pathInfo, 0, strlen($pathInfo) - strlen($urlKeySuffix));
$path = explode('/', $pathInfo);
if (count($path) == 1) {
$request->setActionName('article');
//.........这里部分代码省略.........