18
18
use Magento \PageBuilder \Model \Config as PageBuilderConfig ;
19
19
use Magento \PageBuilder \Model \State as PageBuilderState ;
20
20
use Magento \PageBuilder \Model \Stage \Config as Config ;
21
+ use Magento \Framework \AuthorizationInterface ;
21
22
22
23
/**
23
24
* Updates wysiwyg element with Page Builder specific config
26
27
*/
27
28
class Wysiwyg extends \Magento \Ui \Component \Form \Element \Wysiwyg
28
29
{
30
+
31
+ public const ADMIN_RESOURCE = 'Magento_Backend::content ' ;
32
+
29
33
/**
30
34
* @var Repository
31
35
*/
32
36
private $ assetRepo ;
33
37
38
+ /**
39
+ * @var AuthorizationInterface
40
+ */
41
+ private $ authorization ;
42
+
34
43
/**
35
44
* WYSIWYG Constructor
36
45
*
@@ -62,9 +71,11 @@ public function __construct(
62
71
array $ config = [],
63
72
PageBuilderConfig $ pageBuilderConfig = null ,
64
73
bool $ overrideSnapshot = false ,
65
- Repository $ assetRepo = null
74
+ Repository $ assetRepo = null ,
75
+ AuthorizationInterface $ authorization = null
66
76
) {
67
77
$ this ->assetRepo = $ assetRepo ?: ObjectManager::getInstance ()->get (Repository::class);
78
+ $ this ->authorization = $ authorization ?: ObjectManager::getInstance ()->get (AuthorizationInterface::class);
68
79
$ wysiwygConfigData = $ config ['wysiwygConfigData ' ] ?? [];
69
80
70
81
// If a dataType is present we're dealing with an attribute
@@ -79,11 +90,11 @@ public function __construct(
79
90
$ config ['wysiwyg ' ] = true ;
80
91
}
81
92
}
82
-
93
+ $ isAllowed = $ this -> authorization -> isAllowed ( self :: ADMIN_RESOURCE );
83
94
$ isEnablePageBuilder = isset ($ wysiwygConfigData ['is_pagebuilder_enabled ' ])
84
95
&& !$ wysiwygConfigData ['is_pagebuilder_enabled ' ]
85
96
|| false ;
86
- if (!$ pageBuilderState ->isPageBuilderInUse ($ isEnablePageBuilder )) {
97
+ if (!$ pageBuilderState ->isPageBuilderInUse ($ isEnablePageBuilder ) && $ isAllowed ) {
87
98
// This is not done using definition.xml due to https://github.com/magento/magento2/issues/5647
88
99
$ data ['config ' ]['component ' ] = 'Magento_PageBuilder/js/form/element/wysiwyg ' ;
89
100
0 commit comments