-
Notifications
You must be signed in to change notification settings - Fork 6
/
TemplateProcessorBlock.php
33 lines (27 loc) · 1.28 KB
/
TemplateProcessorBlock.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require dirname(__FILE__) . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
class Outslide extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
$this->_state->setAreaCode('frontend');
// $this->_state->setAreaCode('adminhtml');
// $this->_state->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND);
// $this->_state->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
$block = $this->_objectManager->create('\Magento\Cms\Model\Block');
$filterProvider = $this->_objectManager->create('Magento\Cms\Model\Template\FilterProvider');
$storeManager = $this->_objectManager->create('Magento\Store\Model\StoreManagerInterface');
$blockId = 1; // Id of block you want get content
$storeId = $storeManager->getStore()->getId();
$block->setStoreId($storeId)->load($blockId);
$content = $block->getContent();
$html = $filterProvider->getBlockFilter()->setStoreId($storeId)->filter($content);
echo $html;
//the method must end with this line
return $this->_response;
}
}
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Outslide');
$bootstrap->run($app);