本文整理汇总了PHP中Mage_Core_Controller_Varien_Action::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Controller_Varien_Action::getRequest方法的具体用法?PHP Mage_Core_Controller_Varien_Action::getRequest怎么用?PHP Mage_Core_Controller_Varien_Action::getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Controller_Varien_Action
的用法示例。
在下文中一共展示了Mage_Core_Controller_Varien_Action::getRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _authorizeFrontendAccess
/**
* Authorize store access
*
* @param Mage_Core_Controller_Varien_Action $action
*/
protected function _authorizeFrontendAccess($action)
{
/* @var $session Mage_Customer_Model_Session */
$session = Mage::getSingleton('customer/session');
/* @var $helper Tangkoko_Authorization_Helper_Store */
$helper = Mage::helper('tangkoko_authorization/store');
// Check if customer is authorized
if (!$helper->isAuthorized($session->getCustomer())) {
$request = $action->getRequest();
$path = $action->getFullActionName('/');
$allowedActions = $helper->getPublicActions();
if ($allowedActions != "" && preg_match($allowedActions, $path)) {
// Do not redirect on allowed actions
return;
} elseif (preg_match('#^cms/#', $path)) {
// Do not redirect on allowed CMS page
$identifier = $request->getParam('page_id', $request->getParam('id', Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE)));
$page = Mage::getModel('cms/page')->load($identifier);
if (in_array($page->getIdentifier(), $helper->getPublicCmsPages())) {
return;
}
}
// Path is not an allowed page or action
$url = null;
$parameters = array();
$message = null;
$redirectMode = null;
// Define redirect mode
if ($session->isLoggedIn()) {
// Customer is loged in
$redirectMode = $helper->getUnauthorizedCustomerRedirect();
} else {
// Customer is not logged in
$redirectMode = $helper->getAnonymousCustomerRedirect();
}
// Define redirection parameters depending on redirect mode
if ($redirectMode == Tangkoko_Authorization_Helper_Store::PAGE_REDIRECT) {
// Page redirection
$url = $helper->getErrorPage();
} elseif ($redirectMode == Tangkoko_Authorization_Helper_Store::CUSTOM_REDIRECT) {
// Url redirection
$url = $helper->getCustomRedirectUrl();
} elseif ($redirectMode == Tangkoko_Authorization_Helper_Store::LOGIN_REDIRECT) {
// Visitor with redirect mode equal to login
$url = Mage_Customer_Helper_Data::ROUTE_ACCOUNT_LOGIN;
$parameters = Mage::helper('customer')->getLoginUrlParams();
}
// Get redirect message
$message = $helper->getErrorMessage();
if (!empty($message)) {
$errorMessage = new Mage_Core_Model_Message_Error($message);
$session->addUniqueMessages($errorMessage);
}
return Mage::app()->getResponse()->setRedirect(Mage::getUrl($url, $parameters));
}
}
示例2: testAddPageLayoutHandles
/**
* @magentoAppIsolation enabled
*/
public function testAddPageLayoutHandles()
{
$this->_model->getRequest()->setRouteName('test')->setControllerName('controller')->setActionName('action');
//$this->_model->addPageLayoutHandles(array());
$this->assertEmpty($this->_model->getLayout()->getUpdate()->getHandles());
$this->_model->getRequest()->setRouteName('catalog')->setControllerName('product')->setActionName('view');
$this->_model->addPageLayoutHandles(array('type' => 'simple'));
$handles = $this->_model->getLayout()->getUpdate()->getHandles();
$this->assertContains('default', $handles);
$this->assertContains('catalog_product_view', $handles);
$this->assertContains('catalog_product_view_type_simple', $handles);
}
示例3: testNoRouteAction
public function testNoRouteAction()
{
$status = 'test';
$this->_model->getRequest()->setParam('__status__', $status);
$caughtException = false;
$message = '';
try {
$this->_model->norouteAction();
} catch (Exception $e) {
$caughtException = true;
$message = $e->getMessage();
}
$this->assertFalse($caughtException, $message);
}
示例4: authenticate
/**
* Authenticate controller action by login customer
*
* @param Mage_Core_Controller_Varien_Action $action
* @param bool $loginUrl
* @return bool
*/
public function authenticate(Mage_Core_Controller_Varien_Action $action, $loginUrl = null)
{
if (!$this->_getSession()->isLoggedIn()) {
if ($action->getRequest()->isAjax()) {
$this->_getSession()->setBeforeVendorAuthUrl(Mage::getUrl('*/vendor/', array('_current' => true, '_secure' => true, '_nosid' => true)));
} else {
$oAuthUrl = Mage::getUrl('*/*/*', array('_current' => true, '_secure' => true, '_nosid' => true));
$this->_getSession()->setBeforeVendorAuthUrl($oAuthUrl);
}
if (is_null($loginUrl)) {
if (Mage::getConfig()->getModuleConfig('Ced_CsVendorPanel')->is('active', 'true')) {
$url = 'csmarketplace/account/login';
} else {
$url = 'customer/account/login';
}
$loginUrl = Mage::getUrl($url, array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure(), '_nosid' => true));
}
if ($action->getRequest()->isAjax()) {
$ajaxResponse = array();
$ajaxResponse['ajaxExpired'] = true;
$ajaxResponse['ajaxRedirect'] = $loginUrl;
$action->getResponse()->setBody(json_encode($ajaxResponse));
return;
}
$action->getResponse()->setRedirect($loginUrl);
return false;
}
if ($this->_getSession()->isLoggedIn() && Mage::helper('csmarketplace')->authenticate($this->_getSession()->getCustomerId())) {
$vendor = Mage::getModel('csmarketplace/vendor')->loadByCustomerId($this->_getSession()->getCustomerId());
if ($vendor && $vendor->getId()) {
$this->_getSession()->setData('vendor_id', $vendor->getId());
$this->_getSession()->setData('vendor', $vendor);
Mage::dispatchEvent('ced_csmarketplace_vendor_authenticate_after', array('session' => $this->_getSession()));
}
}
Mage::dispatchEvent('ced_csmarketplace_vendor_acl_check', array('current' => $this, 'action' => $action));
return $this->_allowedResource;
}