![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/app/code/Soon/CsBlock/Model/ |
<?php /** * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @author Hervé Guétin <[email protected]> <@herveguetin> * @copyright Copyright (c) 2017 Agence Soon (http://www.agence-soon.fr) */ namespace Soon\CsBlock\Model; use Magento\Framework\Model\AbstractModel; use Magento\Framework\Model\Context; use Magento\Framework\Registry; use Soon\CsBlock\Model\ResourceModel\Block as BlockResource; use Soon\CsBlock\Model\ResourceModel\Block\Collection; class Block extends AbstractModel implements BlockInterface { const DEFAULT_RENDERER_CLASS_NAME = '\Magento\Framework\View\Element\Template'; /** * @var BlockTypeInterface */ private $blockType; public function __construct( Context $context, Registry $registry, BlockResource $resource, Collection $resourceCollection, BlockTypeInterface $blockType, array $data = [] ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->blockType = $blockType; } protected function _construct() { $this->_init('Soon\CsBlock\Model\ResourceModel\Block'); } /** * @return string */ public function getRendererClassName(): string { $blockTypeConfig = $this->getBlockTypeConfig(); return (isset($blockTypeConfig['frontend_renderer']['class'])) ? $blockTypeConfig['frontend_renderer']['class'] : self::DEFAULT_RENDERER_CLASS_NAME; } /** * @return array */ private function getBlockTypeConfig() { $content = $this->getContent(); return $this->blockType->getTypeConfig($content['block_type']); } /** * @return array */ public function getContent(): array { return unserialize($this->getData('content')); } /** * @return string */ public function getRendererTemplate(): string { $blockTypeConfig = $this->getBlockTypeConfig(); return $blockTypeConfig['frontend_renderer']['template'] ?? ""; } /** * @return string */ public function getType(): string { return $this->getContent()['block_type']; } }