From 89465dcc78f7296113967d572cc22fdbb43529bf Mon Sep 17 00:00:00 2001 From: Alessandro Ronchi Date: Fri, 11 Mar 2016 16:47:29 +0100 Subject: [PATCH] Add dispatching of view_block_abstract_to_html_after event Just like it was in Magento 1 Mage_Core_Block_Abstract class, this change is aimed at having an event dispatched after the HTML is generated by the toHtml() method. This can be used to change HTML without the need to implement a plugin for this class. --- .../Magento/Framework/View/Element/AbstractBlock.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index e84a5d090897e..8a50f33b8f68c 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -654,6 +654,15 @@ public function toHtml() } } $html = $this->_afterToHtml($html); + + /** @var \Magento\Framework\DataObject */ + $transportObject = new \Magento\Framework\DataObject( + [ + 'html' => $html, + ] + ); + $this->_eventManager->dispatch('view_block_abstract_to_html_after', ['block' => $this, 'transport' => $transportObject]); + $html = $transportObject->getHtml(); return $html; }