Skip to content

Commit

Permalink
Merge pull request #24 from hostep/fix-issue-23
Browse files Browse the repository at this point in the history
Fixes issue 23: make sure cms block content is correct in Magento 2.2.4 and 2.2.5
  • Loading branch information
sydekumf authored Aug 23, 2018
2 parents d36722d + e1afe1d commit 08f0dd2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions Plugin/Cms/Model/Block/BlockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

namespace Magenerds\PageDesigner\Plugin\Cms\Model\Block;

use Magento\Cms\Api\Data\BlockInterface;
use Magenerds\PageDesigner\Constants;
use Magenerds\PageDesigner\Utils\HtmlRendererInterface;
use Magento\Cms\Model\Block;
use Magento\Cms\Model\ResourceModel\Block as BlockResource;

/**
* Class BlockPlugin
Expand Down Expand Up @@ -43,13 +45,14 @@ public function __construct(HtmlRendererInterface $htmlRenderer)
/**
* Manipulates the Block entity before it is saved
*
* @param BlockInterface $block
* @param BlockResource $blockResource
* @param Block $block
* @param array $arguments
*/
public function beforeSave(BlockInterface $block, ... $arguments) // NOSONAR
public function beforeSave(BlockResource $blockResource, Block $block, ... $arguments) // NOSONAR
{
/** @noinspection PhpUndefinedMethodInspection */
$json = $block->getPageDesignerJson();
$json = $block->getData(Constants::ATTR_PAGE_DESIGNER_JSON);

if (strlen(trim($json)) > 0) {
$block->setContent($this->htmlRenderer->toHtml($json));
Expand Down
3 changes: 1 addition & 2 deletions Plugin/Cms/Model/Page/PagePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace Magenerds\PageDesigner\Plugin\Cms\Model\Page;

use Magenerds\PageDesigner\Constants;
use Magento\Cms\Api\Data\PageInterface;
use Magenerds\PageDesigner\Utils\HtmlRendererInterface;
use Magento\Cms\Model\Page;
use Magento\Cms\Model\ResourceModel\Page as PageResource;
Expand Down Expand Up @@ -47,7 +46,7 @@ public function __construct(HtmlRendererInterface $htmlRenderer)
* Manipulates the Page entity before it is saved
*
* @param PageResource $pageResource
* @param PageInterface|Page $page
* @param Page $page
* @param array $arguments
*/
public function beforeSave(PageResource $pageResource, Page $page, ... $arguments) // NOSONAR
Expand Down
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
type="Magenerds\PageDesigner\Plugin\Cms\Model\Page\PagePlugin" sortOrder="100"/>
</type>

<type name="Magento\Cms\Model\Block">
<type name="Magento\Cms\Model\ResourceModel\Block">
<plugin name="Magenerds_PageDesigner::cmsBlockRenderJson"
type="Magenerds\PageDesigner\Plugin\Cms\Model\Block\BlockPlugin" sortOrder="100"/>
</type>
Expand Down

0 comments on commit 08f0dd2

Please sign in to comment.