Skip to content

Commit

Permalink
fix error cannot load widget content
Browse files Browse the repository at this point in the history
  • Loading branch information
miha authored and JaJuMa committed May 31, 2022
1 parent 84593bf commit ac92a4e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
16 changes: 16 additions & 0 deletions Block/Widgets/Faq/Questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
use Magento\Widget\Model\Widget\Instance;
use Magento\Widget\Helper\Conditions;

class Questions extends Template
{
Expand Down Expand Up @@ -46,6 +47,11 @@ class Questions extends Template
*/
protected $coreRegistry;

/**
* @var Conditions
*/
private $conditionsHelper;

/**
* Items constructor.
* @param TemplateContext $context
Expand All @@ -61,13 +67,15 @@ public function __construct(
Config $wysiwygConfig,
Data $advancedWidgetHelper,
Registry $coreRegistry,
Conditions $conditionsHelper,
$data = []
)
{
$this->elementFactory = $elementFactory;
$this->wysiwygConfig = $wysiwygConfig;
$this->advancedWidgetHelper = $advancedWidgetHelper;
$this->coreRegistry = $coreRegistry;
$this->conditionsHelper = $conditionsHelper;
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -183,4 +191,12 @@ public function getAdvancedWidgetHelper()
return $this->advancedWidgetHelper;
}

/**
* @return Data
*/
public function getConditionsHelper()
{
return $this->conditionsHelper;
}

}
4 changes: 2 additions & 2 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Widget\Controller\Adminhtml\Widget\LoadOptions">
<!-- <type name="Magento\Widget\Controller\Adminhtml\Widget\LoadOptions">
<plugin name="rewrite_widget_load_options"
type="Jajuma\HyvaFaq\Plugin\Widget\Controller\Adminhtml\Widget\LoadOptions"/>
</type>
</type> -->

<type name="Magento\Backend\Model\Menu\Item">
<plugin name="jajumaExtensionsLink" type="Jajuma\HyvaFaq\Plugin\Backend\Model\Menu\Item\ExtensionsLinkPlugin"/>
Expand Down
12 changes: 11 additions & 1 deletion view/adminhtml/templates/widget/faq/questions.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@
use Jajuma\AdvancedWidget\Block\Widgets\Faq\Questions;
/** @var Questions $block * */

$questionsGroup = count($block->getWidgetContentValues()) ? ($block->getWidgetContentValues())['conditions'] : null;
$contentValues = $block->getWidgetContentValues();
if(count($contentValues)) {
if (array_key_exists('conditions',$contentValues)) {
$questionsGroup = $contentValues['conditions'];
} else {
$questionsGroup = $block->getConditionsHelper()->decode($contentValues['conditions_encoded']);
}
} else {
$questionsGroup = null;
}

?>
<div class="admin__scope-old">
<fieldset class="fieldset">
Expand Down

0 comments on commit ac92a4e

Please sign in to comment.