Skip to content

Commit

Permalink
Add doNotRender method to BaseModel
Browse files Browse the repository at this point in the history
  • Loading branch information
HansSchouten committed Jul 26, 2023
1 parent df56345 commit f7c9e11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Modules/GrapesJS/Block/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class BaseModel
*/
protected $forPageBuilder;

/**
* @var bool $doNotRender
*/
protected $doNotRender;

/**
* BaseModel constructor.
*
Expand Down Expand Up @@ -96,4 +101,14 @@ public function childData($childBlockId)
return $this->data['blocks'][$childBlockId] ?? null;
}

/**
* Whether this page is rendered on the webpage.
*
* @return false
*/
public function doNotRender(): bool
{
return $this->doNotRender ?? false;
}

}
3 changes: 3 additions & 0 deletions src/Modules/GrapesJS/Block/BlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ protected function renderDynamicBlock(ThemeBlock $themeBlock, $blockData)
require_once $themeBlock->getModelFile();
$modelClass = $themeBlock->getModelClass();
$model = new $modelClass($themeBlock, $blockData, $this->page, $this->forPageBuilder);
if ($model->doNotRender()) {
return '';
}
}

if ($themeBlock->getControllerFile()) {
Expand Down

0 comments on commit f7c9e11

Please sign in to comment.