From 8385aa8a3a63857184d9944bcb722c442ff5001c Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 9 Apr 2020 15:41:19 +0300 Subject: [PATCH 1/3] support tinyMCE3 --- .../Plugin/UpdateWysiwygDialogUrlTinyMce.php | 53 +++++++++++++++++++ MediaGalleryIntegration/etc/adminhtml/di.xml | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php diff --git a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php new file mode 100644 index 000000000000..2ac7f385a4b4 --- /dev/null +++ b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php @@ -0,0 +1,53 @@ +url = $url; + $this->config = $config; + } + + /** + * Update open media gallery dialog URL for image-uploader component + * + * @param Image $component + */ + public function afterPrepare(DataObject $config): void + { + if (!$this->config->isEnabled()) { + return; + } + $config->setData('files_browser_window_url', $this->url->getUrl('media_gallery/index/index')); + } +} diff --git a/MediaGalleryIntegration/etc/adminhtml/di.xml b/MediaGalleryIntegration/etc/adminhtml/di.xml index be573fb88398..9e4822345701 100644 --- a/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -15,4 +15,7 @@ + + + From edad42aa69d859ffd4ec7283814ee74eef340ae4 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 9 Apr 2020 18:30:23 +0300 Subject: [PATCH 2/3] correct method --- .../Plugin/UpdateWysiwygDialogUrlTinyMce.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php index 2ac7f385a4b4..4b03d2be8029 100644 --- a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php +++ b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php @@ -12,9 +12,9 @@ use Magento\MediaGalleryUiApi\Api\ConfigInterface; /** - * Plugin to update open media gallery dialog URL for image-uploader component + * Plugin to update open media gallery dialog URL for tinyMCE3 */ -class UpdateWysiwygOpenDialogUrlTinyMce +class UpdateWysiwygDialogUrlTinyMce { /** * @var UrlInterface @@ -39,15 +39,18 @@ public function __construct( } /** - * Update open media gallery dialog URL for image-uploader component + * Update open media gallery dialog URL for wysiwyg instance * - * @param Image $component + * @param DataObject $config */ - public function afterPrepare(DataObject $config): void + public function afterGetConfig($subject, DataObject $config): DataObject { if (!$this->config->isEnabled()) { - return; + return $config; } + $config->setData('files_browser_window_url', $this->url->getUrl('media_gallery/index/index')); + + return $config; } } From 0b6fd71cddbf86c2d7dc992acd505e3885196391 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 9 Apr 2020 18:36:55 +0300 Subject: [PATCH 3/3] fix static tests --- .../Plugin/UpdateWysiwygDialogUrlTinyMce.php | 5 ++++- MediaGalleryIntegration/composer.json | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php index 4b03d2be8029..0683c230e4b8 100644 --- a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php +++ b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php @@ -10,6 +10,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\DataObject; use Magento\MediaGalleryUiApi\Api\ConfigInterface; +use Magento\Tinymce3\Model\Config\Gallery\Config; /** * Plugin to update open media gallery dialog URL for tinyMCE3 @@ -41,9 +42,11 @@ public function __construct( /** * Update open media gallery dialog URL for wysiwyg instance * + * @param Config $subject * @param DataObject $config + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterGetConfig($subject, DataObject $config): DataObject + public function afterGetConfig(Config $subject, DataObject $config): DataObject { if (!$this->config->isEnabled()) { return $config; diff --git a/MediaGalleryIntegration/composer.json b/MediaGalleryIntegration/composer.json index 251b30a55a52..f568bf946280 100644 --- a/MediaGalleryIntegration/composer.json +++ b/MediaGalleryIntegration/composer.json @@ -7,7 +7,8 @@ "magento/module-ui": "*", "magento/module-media-gallery-ui-api": "*", "magento/module-media-gallery-ui": "*", - "magento/module-cms": "*" + "magento/module-cms": "*", + "magento/module-tinymce-3": "*" }, "type": "magento2-module", "license": [