本文整理汇总了PHP中Mage_Core_Controller_Front_Action::preDispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Controller_Front_Action::preDispatch方法的具体用法?PHP Mage_Core_Controller_Front_Action::preDispatch怎么用?PHP Mage_Core_Controller_Front_Action::preDispatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Controller_Front_Action
的用法示例。
在下文中一共展示了Mage_Core_Controller_Front_Action::preDispatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDispatch
/**
* Make sure the customer is authenticated of necessary
*
* @return Mage_Core_Controller_Front_Action | void
*/
public function preDispatch()
{
parent::preDispatch();
if (!$this->getRequest()->isDispatched()) {
return;
}
$authenticationRequired = (bool) Mage::getStoreConfig(Solvingmagento_AffiliateProduct_Model_Product_Type::XML_PATH_AUTHENTICATION);
if ($authenticationRequired) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
if ($customer && $customer->getId()) {
$validationResult = $customer->validate();
if (true !== $validationResult && is_array($validationResult)) {
foreach ($validationResult as $error) {
Mage::getSingleton('core/session')->addError($error);
}
$this->goBack();
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
return $this;
}
return $this;
} else {
Mage::getSingleton('customer/session')->addError($this->helper->__('You must log in to access the partner product'));
$this->_redirect('customer/account/login');
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
return $this;
}
}
}
示例2: preDispatch
/**
* Ensure that the a database connection exists
* If not, do load the route
*
* @return $this
*/
public function preDispatch()
{
if (Mage::registry('wordpress_controller')) {
Mage::unregister('wordpress_controller');
}
Mage::register('wordpress_controller', $this);
parent::preDispatch();
try {
if (!$this->_canRunUsingConfig()) {
$this->_forceForwardViaException('noRoute');
return;
}
if ($this->getRequest()->getParam('feed_type')) {
$this->getRequest()->setParam('feed', $this->getRequest()->getParam('feed_type'));
// Legacy fix
if (strpos(strtolower($this->getRequest()->getActionName()), 'feed') === false) {
$this->_forceForwardViaException('feed');
return;
}
}
} catch (Mage_Core_Controller_Varien_Exception $e) {
throw $e;
} catch (Exception $e) {
Mage::helper('wordpress')->log($e->getMessage());
$this->_forceForwardViaException('noRoute');
return;
}
// Check for redirects and forwards
$transport = new Varien_Object();
Mage::dispatchEvent('wordpress_' . strtolower(substr(get_class($this), strlen('Fishpig_Wordpress_'), -strlen('Controller'))) . '_controller_pre_dispatch_after', array('transport' => $transport, 'action' => $this));
if ($transport->getForward()) {
return $this->_forward($transport->getForward()->getAction(), $transport->getForward()->getController(), $transport->getForward()->getModule());
}
return $this;
}
示例3: preDispatch
/**
* Predispatch: shoud set layout area
*
* @return Mage_Core_Controller_Front_Action
*/
public function preDispatch()
{
try {
// call the parents class method
parent::preDispatch();
// resolve the needed parameters from the requested resource name
$this->_params = Mage::helper('channel')->resolve($this->getRequest()->getRequestString());
// return the instance itself
return $this;
} catch (Faett_Channel_Exceptions_ResourceNotFoundException $rnfe) {
// log the exception
Mage::logException($rnfe);
// register the error message
Mage::register(Faett_Channel_Block_NotFound::MESSAGE, $this->_getHelper()->__($rnfe->getKey()));
// forward to the not found page
$this->_forward('notFound', 'error', 'channel');
} catch (Exception $e) {
// log the exception
Mage::logException($e);
// register the error message
Mage::register(Faett_Channel_Block_InternalServerError::MESSAGE, $e->getMessage());
// forward to the internal server error page
$this->_forward('internalServerError', 'error', 'channel');
}
}
示例4: preDispatch
/**
* Ensure that the a database connection exists
* If not, do load the route
*
* @return $this
*/
public function preDispatch()
{
if (Mage::registry('wordpress_controller')) {
Mage::unregister('wordpress_controller');
}
Mage::register('wordpress_controller', $this);
parent::preDispatch();
try {
if (!$this->_canRunUsingConfig()) {
$this->_forceForwardViaException('noRoute');
return;
}
if ($this->getRequest()->getParam('feed')) {
if (strpos(strtolower($this->getRequest()->getActionName()), 'feed') === false) {
$this->_forceForwardViaException('feed');
return;
}
}
} catch (Mage_Core_Controller_Varien_Exception $e) {
throw $e;
} catch (Exception $e) {
Mage::helper('wordpress')->log($e->getMessage());
$this->_forceForwardViaException('noRoute');
return;
}
return $this;
}
示例5: preDispatch
/**
* Use 'admin' store and prevent the session from starting
*
* @return Mage_Api_Controller_Action
*/
public function preDispatch()
{
Mage::app()->setCurrentStore('admin');
$this->setFlag('', self::FLAG_NO_START_SESSION, 1);
parent::preDispatch();
return $this;
}
示例6: preDispatch
public function preDispatch()
{
parent::preDispatch();
$this->apiUrl = Mage::getStoreConfig(self::WMS_API_URL);
$this->apiUser = Mage::getStoreConfig(self::WMS_API_USER);
$this->apiPassword = Mage::getStoreConfig(self::WMS_API_PASSWORD);
}
示例7: preDispatch
/**
* Checking if user is logged in or not
* If not logged in then redirect to customer login
*/
public function preDispatch()
{
parent::preDispatch();
if (!$this->customerSession()->authenticate($this)) {
$this->setFlag('', 'no-dispatch', true);
}
}
示例8: preDispatch
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getStoreConfigFlag(self::XML_PATH_ENABLED)) {
$this->norouteAction();
}
}
示例9: preDispatch
/**
* disables any punchnout only tests
*
* @return Mage_Core_Controller_Front_Action|void
*/
public function preDispatch()
{
// for any actions within this controller, disable the punchout only test.
$event = Mage::getConfig()->getEventConfig('frontend', 'controller_action_predispatch');
$event->observers->session_check_punchout_only->type = 'disabled';
parent::preDispatch();
}
示例10: preDispatch
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
}
}
示例11: preDispatch
/**
* Action predispatch
*
* Check customer authentication for some actions
*/
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->authenticate($this)) {
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
}
}
示例12: preDispatch
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getStoreConfigFlag('productlist/general_setting/show')) {
$this->norouteAction();
}
}
示例13: preDispatch
public function preDispatch()
{
parent::preDispatch();
if (!$this->_getSession()->authenticate($this) || !Mage::helper('palorus')->isVaultEnabled()) {
$this->setFlag('', 'no-dispatch', true);
}
}
示例14: preDispatch
public function preDispatch()
{
$this->setFlag('', self::FLAG_NO_START_SESSION, 1);
// Do not start standart session
parent::preDispatch();
return $this;
}
示例15: preDispatch
/**
* require login when access this controller
*/
public function preDispatch()
{
parent::preDispatch();
if (!$this->getRequest()->isDispatched()) {
return;
}
// David - Update create user
if (Mage::helper('usermanagement')->isEnable() && Mage::getSingleton('customer/session')->getCustomerId() && !Mage::helper('usermanagement')->isExistUser()) {
// Create new user
Mage::getSingleton('usermanagement/observer')->customerRegister(new Varien_Object(array('customer' => Mage::getSingleton('customer/session')->getCustomer())));
}
// David - End update create user
if (!Mage::helper('usermanagement')->isEnable() || !Mage::helper('usermanagement')->isExistUser()) {
$this->_redirect('customer/account');
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
return;
}
if (!Mage::getSingleton('customer/session')->authenticate($this)) {
$this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
} else {
$user = Mage::getSingleton('core/session')->getData('usermanagement_user');
if (!$user || !$user->getId()) {
$customer = Mage::getSingleton('customer/session')->getCustomer();
$user = Mage::getModel('usermanagement/user')->load($customer->getId(), 'customer_id');
Mage::getSingleton('core/session')->setData('usermanagement_user', $user);
}
}
}