浏览文章
文章信息
Magento2 rest中Cms内容的转义|将rest接口中的CMS内容转为html文本
13492
这是我的核心块:
具体的转化类:
<?php /** * @Author 秋枫雁飞 * @Email aiweline@qq.com/1714255949@qq.com * @Desc 文件由Aiweline(秋枫雁飞)编写,若有升级需要 * 建议不要随意修改文件源码。 **/ namespace Aiweline\Core\Helper\Cms; class Convert { /** * @var \Magento\Cms\Model\Template\FilterProvider */ protected $_filterProvider; /** * @var \Magento\Store\Model\StoreManagerInterface */ protected $_storeManager; /**3 * Convert 初始化... * @param \Magento\Cms\Model\Template\FilterProvider $filterProvider * @param \Magento\Store\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Cms\Model\Template\FilterProvider $filterProvider, \Magento\Store\Model\StoreManagerInterface $storeManager ) { $this->_filterProvider = $filterProvider; $this->_storeManager = $storeManager; } /** * @Desc | 转化静态block到html * @param $content * @return mixed * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getContentFromStaticBlock($content) { $storeId = $this->_storeManager->getStore()->getId(); return $this->_filterProvider->getBlockFilter()->setStoreId($storeId)->filter($content); } }这个类可以实现cms内容转化为html.