本文整理汇总了PHP中Varien_Event_Observer::getControllerAction方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getControllerAction方法的具体用法?PHP Varien_Event_Observer::getControllerAction怎么用?PHP Varien_Event_Observer::getControllerAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getControllerAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkForLogin
public function checkForLogin(Varien_Event_Observer $observer)
{
if (Mage::app()->getWebsite()->getId() == Mage::helper("mey_b2b")->getWebsiteId()) {
$allow = array('customer_account_login', 'customer_account_forgotpassword', 'customer_account_resetpassword', 'customer_account_loginpost', 'customer_account_forgotpasswordpost', 'customer_account_resetpasswordpost', 'customer_account_createb2b', 'customer_account_createb2bpost', 'customer_account_createb2bsuccess', 'mey_b2bcustomer_index_approve', 'mey_b2bcustomer_index_disapprove', 'turpentine_esi_getblock');
$allowCms = array("/newsletter/", "/newsletter-abmelden/");
$disallowRoute = false;
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
if ($observer->getControllerAction()->getFullActionName() === "cms_page_view") {
$pathInfo = Mage::app()->getFrontController()->getRequest()->getOriginalPathInfo();
if (!in_array($pathInfo, $allowCms)) {
$disallowRoute = true;
}
} else {
if (!in_array(strtolower($observer->getControllerAction()->getFullActionName()), $allow)) {
$disallowRoute = true;
}
}
}
if ($disallowRoute) {
$fullRequestUrl = Mage::app()->getRequest()->getScheme() . "://" . Mage::app()->getRequest()->getHttpHost() . Mage::app()->getRequest()->getRequestUri();
Mage::getSingleton("customer/session")->setBeforeAuthUrl($fullRequestUrl);
Mage::app()->getResponse()->setRedirect(Mage::helper("customer")->getLoginUrl())->sendResponse();
exit;
}
}
}
示例2: addSortableScriptOnGrid
/**
* Appends the "sortable" js code to the bottom of ajax-Request for the category-products loaded after
* changing sort order.
*
* @param Varien_Event_Observer $observer
*/
public function addSortableScriptOnGrid($observer)
{
if (Mage::helper('hackathon_productdnd')->isActivated() && $observer->getControllerAction()->getRequest()->getParam('sort') == 'position') {
$content = $observer->getControllerAction()->getResponse()->getBody();
$content = $this->appendScript($content);
$observer->getControllerAction()->getResponse()->setBody($content);
}
}
示例3: SetFormKey
/**
* Set the current form key for Login form
*/
public function SetFormKey(Varien_Event_Observer $observer)
{
$controller = $observer->getControllerAction();
$request = $controller->getRequest();
$form_key = Mage::getSingleton('core/session')->getFormKey();
$request->setParam('form_key', $form_key);
}
示例4: actionAfter
public function actionAfter(Varien_Event_Observer $o)
{
if ($o->getEvent()->getControllerAction()->getFullActionName() == 'review_product_post') {
Mage::dispatchEvent("review_product_post_after", array('request' => $o->getControllerAction()->getRequest()));
}
return $o;
}
示例5: checkAccess
/**
* MageMagick_Protect_Model_Observer:checkAccess
*
* This method checks if user have permissions for browse store,
* if have no permissions then will be redirected on login page.
*
* NOTE: I think would be better overwrite front controller,
* because observer not intended in general for implement tasks like this,
* but this was fastest way
*
* @param Varien_Event_Observer $observer
* @return mixed
*/
public function checkAccess(Varien_Event_Observer $observer)
{
if (0 === (int) Mage::getStoreConfig('protect/protect/enabled')) {
return $this;
}
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
if (false != $isLoggedIn) {
return $this;
}
$request = Mage::app()->getRequest();
$response = $observer->getControllerAction()->getResponse();
$moduleName = $request->getModuleName();
$controllerName = $request->getControllerName();
$action = $request->getActionName();
// TODO: use Mage::app()->getStore()->isAdmin()
if ($moduleName == 'admin') {
return $this;
}
if ($moduleName != 'customer' && $moduleName != 'cms') {
$this->_hardRedirect($request, $response, Mage::getUrl('/'));
}
self::$addSplashScreen = true;
if ($moduleName == 'cms' && $controllerName == 'index') {
self::$handleId = 'default';
return $this;
}
if ($moduleName == 'customer') {
self::$handleId = $action;
return $this;
}
return $this;
}
示例6: getListproduct
public function getListproduct(Varien_Event_Observer $event)
{
$controller = $event->getControllerAction();
$param = array();
$ajaxcatalog = Mage::app()->getRequest()->getParam('ajaxcatalog');
$layout = Mage::app()->getLayout();
$blocks = array();
if ($ajaxcatalog == 1) {
//$templ = $layout->getBlock('product_list')->setTemplate('ajaxcatalog/list.phtml');
/*
if($templ){
//@header('Content-type: application/json');
$blocks['toolbarlistproduct'] = $templ->toHtml();
echo json_encode($blocks);
exit;
}
$templ = $layout->getBlock('search_result_list');
if($templ){
@header('Content-type: application/json');
$blocks['toolbarlistproduct'] = $templ->toHtml();
echo json_encode($blocks);
}
exit;*/
}
}
示例7: postOrderSave
/**
* This event is called when the MoTo order is saved. The event is fired after the controller action 'save' is executed.
* The event is used to redirect the customer to the payment interface.
*/
public function postOrderSave(Varien_Event_Observer $observer)
{
$controller = $observer->getControllerAction();
$message = Mage::getSingleton('adminhtml/session')->getMessages()->getLastAddedMessage();
if ($message == null) {
return;
}
$messageType = $message->getType();
$redirectLocation = $this->getRedirectionUrl($controller);
Mage::getSingleton('adminhtml/session')->setCustomwebRedirectUrl($redirectLocation);
$orderId = $this->extractOrderId($redirectLocation);
if ($orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
$payment = $order->getPayment();
if (strpos($payment->getMethodInstance()->getCode(), 'saferpaycw') !== false) {
Mage::helper('SaferpayCw')->log("Codes match.");
if ($messageType == 'success') {
$order->addStatusToHistory(Customweb_SaferpayCw_Model_Method::SAFERPAYCW_STATUS_PENDING, Mage::helper('SaferpayCw')->__('Payment is pending at SaferpayCw'));
$order->save();
Mage::helper('SaferpayCw')->log("Redirect to Moto authorization");
Mage::getSingleton('adminhtml/session')->setIsUrlNotice($controller->getFlag('', Mage_Adminhtml_Controller_Action::FLAG_IS_URLS_CHECKED));
$controller->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl('*/motosaferpaycw/process', array('order_id' => $order->getId())));
}
}
}
}
示例8: postdispatch
public function postdispatch(Varien_Event_Observer $event)
{
/* @var $controller Mage_Core_Controller_Varien_Action */
$controller = $event->getControllerAction();
if (!$controller->getRequest()->getHeader('X-Requested-With')) {
return;
}
$param = array();
$headers = Mage::app()->getRequest()->getParams();
foreach ($headers as $headerName => $headerValue) {
$headerName = strtolower($headerName);
if (!preg_match('/tr(.*)/', $headerName, $regs)) {
continue;
}
$param[str_replace('_', '.', $regs[1])] = $headerValue;
}
//orginal magento ajax request
if (!count($param)) {
return;
}
$layout = Mage::app()->getLayout();
$blocks = array();
foreach ($param as $blockName => $selector) {
$temp = $layout->getBlock($blockName);
$blocks[$blockName] = array('selector' => $selector, 'html' => $temp ? $temp->toHtml() : '');
}
echo json_encode($blocks);
exit;
}
示例9: controller_action_predispatch
/**
* Hook to record all fron controller events
* @param Varien_Event_Observer $observer
*/
public function controller_action_predispatch(Varien_Event_Observer $observer)
{
try {
if (extension_loaded('newrelic')) {
$controllerAction = $observer->getControllerAction();
$request = $controllerAction->getRequest();
$controllerName = explode("_", $request->getControllerName());
if (Mage::getStoreConfig('newrelic/settings/ignore_admin_routes') && $request->getRouteName() == 'adminhtml' || $request->getModuleName() == 'admin' || in_array('adminhtml', $controllerName)) {
Mage::Helper('newrelic')->setAppName(false);
newrelic_ignore_transaction();
newrelic_ignore_apdex();
return $this;
}
if (mage::helper('newrelic')->ignoreModule($request->getModuleName()) === true) {
Mage::Helper('newrelic')->setAppName(false);
newrelic_ignore_transaction();
newrelic_ignore_apdex();
return $this;
}
if (Mage::getStoreConfig('newrelic/settings/named_transactions')) {
$route = $request->getRouteName() . '/' . $request->getControllerName() . '/' . $request->getActionName();
if (Mage::getStoreConfig('newrelic/settings/add_module_to_named_transactions')) {
$route .= ' (module: ' . $request->getModuleName() . ')';
}
newrelic_name_transaction($route);
Mage::Helper('newrelic')->setAppName(true);
return $this;
}
}
} catch (Exception $e) {
mage::logException($e);
}
}
示例10: checkTfaSubmitted
/**
* Listens for the controller_action_postdispatch_adminhtml Event to
* check if an Admin that was sent to either:
* (a) My Account to associate a Two Factor Auth, or
* (b) interstitial page to enter their TFA value
* is attempting to navigate away without performing the necessary TFA action
*
* @event controller_action_postdispatch_adminhtml
* @param Varien_Event_Observer $observer
* @return MageHackDay_TwoFactorAuth_Model_Observer
*/
public function checkTfaSubmitted(Varien_Event_Observer $observer)
{
$request = $observer->getControllerAction()->getRequest();
if ($request->getActionName() == 'logout' || !Mage::helper('twofactorauth')->isActive()) {
return $this;
}
if ($request->getControllerName() == 'twofactorauth') {
return $this;
}
$vRedirectUrl = '';
if ($this->_getAdminhtmlSession()->getTfaNotAssociated()) {
$vRedirectUrl = Mage::helper('adminhtml')->getUrl('adminhtml/twofactorauth/qr');
} else {
if ($this->_getAdminhtmlSession()->getTfaNotEntered()) {
$vRedirectUrl = Mage::helper('adminhtml')->getUrl('adminhtml/twofactorauth/interstitial');
}
}
if ($vRedirectUrl) {
$vAction = $request->getActionName();
Mage::app()->getFrontController()->getAction()->setFlag($vAction, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, TRUE);
$oResponse = Mage::app()->getResponse();
$oResponse->setRedirect($vRedirectUrl);
$oResponse->sendResponse();
}
return $this;
}
示例11: setAutogenerateSku
/**
* Sets sku_autogenerate parameter
*
* The parameter would usually be set via checkbox in the "quick create" form
* but since the SKU field is now a label instead of a text field, it is not included.
*
* @see Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple
* @see event controller_action_predispatch_adminhtml_catalog_product_quickCreate
* @param Varien_Event_Observer $observer
*/
public function setAutogenerateSku(Varien_Event_Observer $observer)
{
$request = $observer->getControllerAction()->getRequest();
$simpleProductRequest = $request->getParam('simple_product');
$simpleProductRequest['sku_autogenerate'] = '1';
$request->setParam('simple_product', $simpleProductRequest);
}
示例12: checkReview
/**
* Check Captcha On Product Reviews Page
*
* @param Varien_Event_Observer $observer
*
* @return Mage_Captcha_Model_Observer
*/
public function checkReview($observer)
{
$formId = 'user_review';
$captchaModel = Mage::helper('captcha')->getCaptcha($formId);
if ($captchaModel->isRequired()) {
$controller = $observer->getControllerAction();
if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
Mage::getSingleton('core/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));
$data = $controller->getRequest()->getPost();
Mage::getSingleton('review/session')->setFormData($data);
if ($this->isOldMagento()) {
$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
if ($redirectUrl = Mage::getSingleton('review/session')->getRedirectUrl(true)) {
$controller->getResponse()->setRedirect($redirectUrl);
return $this;
}
$controller->getResponse()->setRedirect($this->_getRefererUrl($controller));
} else {
//invalidate the formkey, which will force the controller to redirect back to referer
$controller->getRequest()->setParam('form_key', 'Incorrect CAPTCHA.');
}
}
}
return $this;
}
示例13: addCodeToSession
/**
* Sets the coupon code on the quote or on the session
*
* @param Varien_Event_Observer $observer
*/
public function addCodeToSession($observer)
{
$action = $observer->getControllerAction();
if ($this->_isApplicable($action)) {
$this->_helper->applyCodeFromRequest($action->getRequest());
}
return false;
}
示例14: customerLogout
public function customerLogout(Varien_Event_Observer $observer)
{
if (Mage::helper('redirection')->isEnabled() && Mage::helper('redirection')->isoptionEnabled('logout_redirection')) {
if ($this->_CustomerGroup()) {
$observer->getControllerAction()->setRedirectWithCookieCheck(Mage::helper('redirection')->setRedirectOnLogout());
}
}
}
示例15: addPageTag
/**
* Add CMS page tag on all CMS pages except homepage
*
* @param Varien_Event_Observer $observer
*/
public function addPageTag(Varien_Event_Observer $observer)
{
$pageId = $observer->getPage()->getIdentifier();
$homePageId = Mage::getStoreConfig('web/default/cms_home_page');
if ($pageId != $homePageId) {
$observer->getControllerAction()->getLayout()->getUpdate()->addHandle('mbiz_trackingtags_page');
}
}