Skip to content

Commit ff73b07

Browse files
committed
Fix wysiwyg and variables button functionality
1 parent 2ee1a22 commit ff73b07

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/Plugin/WysiwygConfigPlugin.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* integer_net Magento Module
7+
*
8+
* @category IntegerNet\ConfigurableWysiwyg\Plugin
9+
* @package WysiwygConfigPlugin
10+
* @copyright Copyright (c) 2022 integer_net GmbH (http://www.integer-net.de/)
11+
* @author Andreas von Studnitz <avs@integer-net.de>
12+
*/
13+
14+
namespace IntegerNet\ConfigurableWysiwyg\Plugin;
15+
16+
use Magento\Cms\Model\Wysiwyg\Config;
17+
use Magento\Framework\App\Config\ScopeConfigInterface;
18+
use Magento\Framework\Data\Wysiwyg\ConfigProviderInterface;
19+
20+
class WysiwygConfigPlugin
21+
{
22+
/**
23+
* @var ScopeConfigInterface
24+
*/
25+
private $scopeConfig;
26+
27+
public function __construct(
28+
ScopeConfigInterface $scopeConfig
29+
) {
30+
$this->scopeConfig = $scopeConfig;
31+
}
32+
33+
public function beforeGetConfig(
34+
\Magento\Cms\Model\Wysiwyg\Config $subject,
35+
$data = []
36+
) {
37+
if (isset($data['add_variables'])) {
38+
$data['add_variables'] = $this->scopeConfig->isSetFlag('cms/wysiwyg/add_variable');
39+
}
40+
if (isset($data['add_widgets'])) {
41+
$data['add_widgets'] = $this->scopeConfig->isSetFlag('cms/wysiwyg/add_widget');
42+
}
43+
if (isset($data['add_images'])) {
44+
$data['add_images'] = $this->scopeConfig->isSetFlag('cms/wysiwyg/add_image');
45+
}
46+
47+
return [$data];
48+
}
49+
}

src/etc/adminhtml/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
<plugin name="integernet-configurable-wysiwyg"
1010
type="IntegerNet\ConfigurableWysiwyg\Plugin\WysiwygConfigProviderPlugin" sortOrder="10"/>
1111
</type>
12+
<type name="Magento\Cms\Model\Wysiwyg\Config">
13+
<plugin name="integernet-configurable-wysiwyg"
14+
type="IntegerNet\ConfigurableWysiwyg\Plugin\WysiwygConfigPlugin" sortOrder="10"/>
15+
</type>
1216

1317
<type name="IntegerNet\ConfigurableWysiwyg\Plugin\WysiwygConfigProviderPlugin">
1418
<arguments>

0 commit comments

Comments
 (0)