Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Wysiwyg Class Reference
Inheritance diagram for Wysiwyg:
Textarea AbstractElement AbstractForm DataObject

Public Member Functions

 __construct (\Magento\Framework\Data\Form\Element\Factory $factoryElement, \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Framework\Escaper $escaper, \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\Module\Manager $moduleManager, \Magento\Backend\Helper\Data $backendData, array $data=[])
 
 getAfterElementHtml ()
 
 getIsWysiwygEnabled ()
 
- Public Member Functions inherited from Textarea
 __construct (Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, $data=[])
 
 getHtmlAttributes ()
 
 getElementHtml ()
 
- Public Member Functions inherited from AbstractElement
 __construct (Factory $factoryElement, CollectionFactory $factoryCollection, Escaper $escaper, $data=[])
 
 addElement (AbstractElement $element, $after=false)
 
 isAdvanced ()
 
 setAdvanced ($advanced)
 
 getId ()
 
 getType ()
 
 getForm ()
 
 setId ($id)
 
 getHtmlId ()
 
 getName ()
 
 setType ($type)
 
 setForm ($form)
 
 removeField ($elementId)
 
 getHtmlAttributes ()
 
 addClass ($class)
 
 removeClass ($class)
 
 getEscapedValue ($index=null)
 
 setRenderer (RendererInterface $renderer)
 
 getRenderer ()
 
 getElementHtml ()
 
 getBeforeElementHtml ()
 
 getAfterElementHtml ()
 
 getAfterElementJs ()
 
 getLabelHtml ($idSuffix='', $scopeLabel='')
 
 getDefaultHtml ()
 
 getHtml ()
 
 toHtml ()
 
 serialize ($attributes=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 getReadonly ()
 
 getHtmlContainerId ()
 
 addElementValues ($values, $overwrite=false)
 
 lock ()
 
 isLocked ()
 
- Public Member Functions inherited from AbstractForm
 __construct (Factory $factoryElement, CollectionFactory $factoryCollection, $data=[])
 
 addType ($type, $className)
 
 getElements ()
 
 setReadonly ($readonly, $useDisabled=false)
 
 addElement (AbstractElement $element, $after=null)
 
 addField ($elementId, $type, $config, $after=false)
 
 removeField ($elementId)
 
 addFieldset ($elementId, $config, $after=false, $isAdvanced=false)
 
 addColumn ($elementId, $config)
 
 convertToArray (array $arrAttributes=[])
 
 addCustomAttribute ($key, $value)
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Protected Attributes

 $_backendData = null
 
 $_moduleManager = null
 
 $_wysiwygConfig
 
 $_layout
 
- Protected Attributes inherited from AbstractElement
 $_id
 
 $_type
 
 $_form
 
 $_elements
 
 $_renderer
 
 $_advanced = false
 
 $_escaper
 
- Protected Attributes inherited from AbstractForm
 $_elements
 
 $_types = []
 
 $_factoryElement
 
 $_factoryCollection
 
 $customAttributes = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Data Fields inherited from Textarea
const DEFAULT_ROWS = 2
 
const DEFAULT_COLS = 15
 
- Protected Member Functions inherited from AbstractElement
 _escape ($string)
 
 _getUiId ($suffix=null)
 
- Protected Member Functions inherited from AbstractForm
 _construct ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Definition at line 14 of file Wysiwyg.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Data\Form\Element\Factory  $factoryElement,
\Magento\Framework\Data\Form\Element\CollectionFactory  $factoryCollection,
\Magento\Framework\Escaper  $escaper,
\Magento\Cms\Model\Wysiwyg\Config  $wysiwygConfig,
\Magento\Framework\View\LayoutInterface  $layout,
\Magento\Framework\Module\Manager  $moduleManager,
\Magento\Backend\Helper\Data  $backendData,
array  $data = [] 
)
Parameters
\Magento\Framework\Data\Form\Element\Factory$factoryElement
\Magento\Framework\Data\Form\Element\CollectionFactory$factoryCollection
\Magento\Framework\Escaper$escaper
\Magento\Cms\Model\Wysiwyg\Config$wysiwygConfig
\Magento\Framework\View\LayoutInterface$layout
\Magento\Framework\Module\Manager$moduleManager
\Magento\Backend\Helper\Data$backendData
array$data

Definition at line 50 of file Wysiwyg.php.

59  {
60  $this->_wysiwygConfig = $wysiwygConfig;
61  $this->_layout = $layout;
62  $this->_moduleManager = $moduleManager;
63  $this->_backendData = $backendData;
64  parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
65  }
$moduleManager
Definition: products.php:75

Member Function Documentation

◆ getAfterElementHtml()

getAfterElementHtml ( )

Retrieve additional html and put it at the end of element html

Returns
string

Definition at line 72 of file Wysiwyg.php.

73  {
74  $config = $this->_wysiwygConfig->getConfig();
75  $config = json_encode($config->getData());
76 
77  $html = parent::getAfterElementHtml();
78  if ($this->getIsWysiwygEnabled()) {
79  $disabled = $this->getDisabled() || $this->getReadonly();
80  $html .= $this->_layout->createBlock(
81  \Magento\Backend\Block\Widget\Button::class,
82  '',
83  [
84  'data' => [
85  'label' => __('WYSIWYG Editor'),
86  'type' => 'button',
87  'disabled' => $disabled,
88  'class' => 'action-wysiwyg',
89  'onclick' => 'catalogWysiwygEditor.open(\'' . $this->_backendData->getUrl(
90  'catalog/product/wysiwyg'
91  ) . '\', \'' . $this->getHtmlId() . '\')',
92  ]
93  ]
94  )->toHtml();
95  $html .= <<<HTML
96 <script>
97 require([
98  'jquery',
99  'mage/adminhtml/wysiwyg/tiny_mce/setup'
100 ], function(jQuery){
101 
102 var config = $config,
103  editor;
104 
105 editor = new wysiwygSetup(
106  '{$this->getHtmlId()}',
107  config
108 );
109 
110 editor.turnOn();
111 
112 jQuery('#{$this->getHtmlId()}')
113  .addClass('wysiwyg-editor')
114  .data(
115  'wysiwygEditor',
116  editor
117  );
118 });
119 </script>
120 HTML;
121  }
122  return $html;
123  }
$config
Definition: fraud_order.php:17
if( $form)() ?>< script > require(['jquery' mage mage
Definition: save.phtml:15
__()
Definition: __.php:13

◆ getIsWysiwygEnabled()

getIsWysiwygEnabled ( )

Check whether wysiwyg enabled or not

Returns
bool @SuppressWarnings(PHPMD.BooleanGetMethodName)

Definition at line 131 of file Wysiwyg.php.

132  {
133  if ($this->_moduleManager->isEnabled('Magento_Cms')) {
134  return (bool)($this->_wysiwygConfig->isEnabled() && $this->getEntityAttribute()->getIsWysiwygEnabled());
135  }
136 
137  return false;
138  }

Field Documentation

◆ $_backendData

$_backendData = null
protected

Definition at line 21 of file Wysiwyg.php.

◆ $_layout

$_layout
protected

Definition at line 38 of file Wysiwyg.php.

◆ $_moduleManager

$_moduleManager = null
protected

Definition at line 28 of file Wysiwyg.php.

◆ $_wysiwygConfig

$_wysiwygConfig
protected

Definition at line 33 of file Wysiwyg.php.


The documentation for this class was generated from the following file: