From 9929588101e77daa8fc4357d90994990bcf775f0 Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Fri, 9 Nov 2012 10:25:07 -0600 Subject: [PATCH 1/3] Adding ability to prevent dispatching an action, so events can be used to create output - primarily for JSON applications --- app/code/core/Mage/Core/Controller/Varien/Action.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php index 2d683c489a083..226b0e010ca08 100755 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ b/app/code/core/Mage/Core/Controller/Varien/Action.php @@ -38,6 +38,7 @@ abstract class Mage_Core_Controller_Varien_Action implements Mage_Core_Controlle { const FLAG_NO_CHECK_INSTALLATION = 'no-install-check'; const FLAG_NO_DISPATCH = 'no-dispatch'; + const FLAG_NO_DISPATCH_ACTION = 'no-dispatch-action'; const FLAG_NO_PRE_DISPATCH = 'no-preDispatch'; const FLAG_NO_POST_DISPATCH = 'no-postDispatch'; const FLAG_NO_START_SESSION = 'no-startSession'; @@ -469,7 +470,11 @@ public function dispatch($action) */ if (!$this->getFlag('', self::FLAG_NO_DISPATCH)) { Magento_Profiler::start('action_body'); - $this->$actionMethodName(); + + if (!$this->getFlag('', self::FLAG_NO_DISPATCH_ACTION)) { + $this->$actionMethodName(); + } + Magento_Profiler::stop('action_body'); Magento_Profiler::start('postdispatch'); From f444354067bbe3fcbe6ea2341ff92cd5906be9cd Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Wed, 14 Nov 2012 10:40:58 -0600 Subject: [PATCH 2/3] Adding in eventObject/Prefix to Mage_Core_Block_Abstract --- app/code/core/Mage/Core/Block/Abstract.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php index 0bb77cb12d47c..2ac7f544175ae 100644 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ b/app/code/core/Mage/Core/Block/Abstract.php @@ -95,6 +95,19 @@ abstract class Mage_Core_Block_Abstract extends Varien_Object */ protected $_eventManager; + + /** + * The prefix for the customized block events + * @var string + */ + protected $_eventPrefix; + + /** + * The object for the customized block events + * @var string + */ + protected $_eventObject; + /** * Class constructor * @@ -614,6 +627,10 @@ public function setFrameTags($openTag, $closeTag = null) final public function toHtml() { Mage::dispatchEvent('core_block_abstract_to_html_before', array('block' => $this)); + if ($this->_eventPrefix && $this->_eventObject) { + Mage::dispatchEvent($this->_eventPrefix . '_to_html_before', array($this->_eventObject => $this)); + } + if (Mage::getStoreConfig('advanced/modules_disable_output/' . $this->getModuleName())) { return ''; } From 81d6ef6c49a083aec23d37bc67bcc8800bce73d0 Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Mon, 19 Nov 2012 16:00:58 -0600 Subject: [PATCH 3/3] Fixing problem in Mage_Tax_Model_Calculation that effectively prevents and externally provided rates from being used in the system (externally, like modules providing streamlined sales tax lookups, etc). Before tax_rate_data_fetch, the rate_value section of data is unset, so hasRateValue() is ALWAYS null, as there is no reference to the calculation model passed into the event. Without this fix, one has to override this model to fix the event --- app/code/core/Mage/Tax/Model/Calculation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Tax/Model/Calculation.php b/app/code/core/Mage/Tax/Model/Calculation.php index bdc78ae5000fb..b0197122606c9 100644 --- a/app/code/core/Mage/Tax/Model/Calculation.php +++ b/app/code/core/Mage/Tax/Model/Calculation.php @@ -188,7 +188,7 @@ public function getRate($request) $this->unsRateValue(); $this->unsCalculationProcess(); $this->unsEventModuleId(); - Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request)); + Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request, 'sender'=>$this)); if (!$this->hasRateValue()) { $rateInfo = $this->_getResource()->getRateInfo($request); $this->setCalculationProcess($rateInfo['process']);