translateInline = $translateInline; $this->jsonSerializer = $jsonSerializer ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Json::class); $this->base64jsonSerializer = $base64jsonSerializer ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Base64Json::class); $this->layoutCacheKey = $layoutCacheKey ?: \Magento\Framework\App\ObjectManager::getInstance()->get(LayoutCacheKeyInterface::class); } /** * Get blocks from layout by handles * * @return array [\Element\BlockInterface] */ protected function _getBlocks() { $blocks = $this->getRequest()->getParam('blocks', ''); $handles = $this->getRequest()->getParam('handles', ''); if (!$handles || !$blocks) { return []; } $blocks = $this->jsonSerializer->unserialize($blocks); $handles = $this->base64jsonSerializer->unserialize($handles); $layout = $this->_view->getLayout(); $this->layoutCacheKey->addCacheKeys($this->layoutCacheKeyName); $this->_view->loadLayout($handles, true, true, false); $data = []; foreach ($blocks as $blockName) { $blockInstance = $layout->getBlock($blockName); if (is_object($blockInstance)) { $data[$blockName] = $blockInstance; } } return $data; } }