Config.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Tinymce3\Model\Config\Widget;
  8. /**
  9. * Class Config adds widget plugin information required for tinymce3 editor
  10. * @deprecated 100.3.0 use \Magento\Widget\Model\Widget\Config instead
  11. */
  12. class Config implements \Magento\Framework\Data\Wysiwyg\ConfigProviderInterface
  13. {
  14. /**
  15. * @var \Magento\Framework\View\Asset\Repository
  16. */
  17. private $assetRepo;
  18. /**
  19. * @var \Magento\Widget\Model\Widget\Config
  20. */
  21. private $widgetConfig;
  22. /**
  23. * @param \Magento\Framework\View\Asset\Repository $assetRepo
  24. * @param \Magento\Widget\Model\Widget\Config $widgetConfig
  25. */
  26. public function __construct(
  27. \Magento\Framework\View\Asset\Repository $assetRepo,
  28. \Magento\Widget\Model\Widget\Config $widgetConfig
  29. ) {
  30. $this->assetRepo = $assetRepo;
  31. $this->widgetConfig = $widgetConfig;
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
  37. {
  38. $settings = [
  39. 'widget_plugin_src' => $this->getWysiwygJsPluginSrc(),
  40. 'widget_window_url' => $this->widgetConfig->getWidgetWindowUrl($config),
  41. 'widget_types' => $this->widgetConfig->getAvailableWidgets($config),
  42. 'widget_error_image_url' => $this->widgetConfig->getErrorImageUrl(),
  43. 'widget_placeholders' => $this->widgetConfig->getWidgetPlaceholderImageUrls()
  44. ];
  45. return $config->addData($settings);
  46. }
  47. /**
  48. * Return path to tinymce3 widget plugin
  49. *
  50. * @return string
  51. */
  52. private function getWysiwygJsPluginSrc() : string
  53. {
  54. $editorPluginJs = 'Magento_Tinymce3::tiny_mce/plugins/magentowidget/editor_plugin.js';
  55. $result = $this->assetRepo->getUrl($editorPluginJs);
  56. return $result;
  57. }
  58. }