From 5a02d603311b870cd22ebcada49764c2f61c738a Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 7 Apr 2020 15:21:51 -0500 Subject: [PATCH 01/13] magento/magento2#27566: Do not re-load the gallery app, just content --- MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js | 1 + 1 file changed, 1 insertion(+) diff --git a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js index be9768e855e0..0299ba6d4755 100644 --- a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js +++ b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js @@ -45,6 +45,7 @@ define([ this._super(); this.initView(); $(window).on('fileDeleted.enhancedMediaGallery', this.reloadMediaGrid.bind(this)); + $(window).on('reload.MediaGallery', this.reloadGrid.bind(this)); return this; }, From 3fca7f2af7d27d8755ccc665e843b79a5a7b5eda Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 9 Apr 2020 10:15:13 +0300 Subject: [PATCH 02/13] Listen target element id from MediaBrowserutility --- .../view/adminhtml/layout/media_gallery_media_index.xml | 3 --- MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js | 1 - .../view/adminhtml/web/js/grid/columns/image/actions.js | 1 - .../adminhtml/web/js/grid/columns/image/insertImageAction.js | 2 +- MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) diff --git a/MediaGalleryUi/view/adminhtml/layout/media_gallery_media_index.xml b/MediaGalleryUi/view/adminhtml/layout/media_gallery_media_index.xml index f0d40291f745..15d06f60626d 100644 --- a/MediaGalleryUi/view/adminhtml/layout/media_gallery_media_index.xml +++ b/MediaGalleryUi/view/adminhtml/layout/media_gallery_media_index.xml @@ -13,9 +13,6 @@ - - target_element_id - diff --git a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js index 0299ba6d4755..b0ef3117aa15 100644 --- a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js +++ b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image.js @@ -15,7 +15,6 @@ define([ deleteImageUrl: 'media_gallery/image/delete', addSelectedBtnSelector: '#add_selected', deleteSelectedBtnSelector: '#delete_selected', - targetElementId: null, selected: null, fields: { id: 'id', diff --git a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/actions.js b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/actions.js index ad03dd66e759..76f0a1223a18 100644 --- a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/actions.js +++ b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/actions.js @@ -54,7 +54,6 @@ define([ this.imageModel().getSelected(), { onInsertUrl: this.imageModel().onInsertUrl, - targetElementId: this.imageModel().targetElementId, storeId: this.imageModel().storeId } ); diff --git a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/insertImageAction.js b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/insertImageAction.js index 2e814468f35d..041f31b3f9a8 100644 --- a/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/insertImageAction.js +++ b/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/insertImageAction.js @@ -26,7 +26,7 @@ define([ if (record === null) { return false; } - targetElement = this.getTargetElement(config.targetElementId); + targetElement = this.getTargetElement(window.MediabrowserUtility.targetElementId); if (!targetElement.length) { window.MediabrowserUtility.closeDialog(); diff --git a/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js b/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js index 5b7f676aed37..eece69a517cf 100644 --- a/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js +++ b/MediaGalleryUi/view/adminhtml/web/js/image/image-actions.js @@ -61,7 +61,6 @@ define([ this.imageModel().getSelected(), { onInsertUrl: this.imageModel().onInsertUrl, - targetElementId: this.imageModel().targetElementId, storeId: this.imageModel().storeId } ); From 044f3da88a7dd2ba8021431f6e32375f4426481b Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Fri, 10 Apr 2020 14:58:43 +0300 Subject: [PATCH 03/13] Remove dependency to page Builder --- .../Plugin/UpdateOpenDialogUrlPageBuilder.php | 54 ------------------- MediaGalleryIntegration/etc/adminhtml/di.xml | 3 -- 2 files changed, 57 deletions(-) delete mode 100644 MediaGalleryIntegration/Plugin/UpdateOpenDialogUrlPageBuilder.php diff --git a/MediaGalleryIntegration/Plugin/UpdateOpenDialogUrlPageBuilder.php b/MediaGalleryIntegration/Plugin/UpdateOpenDialogUrlPageBuilder.php deleted file mode 100644 index 0c2c5b19848f..000000000000 --- a/MediaGalleryIntegration/Plugin/UpdateOpenDialogUrlPageBuilder.php +++ /dev/null @@ -1,54 +0,0 @@ -url = $url; - $this->config = $config; - } - - /** - * Update open media gallery dialog URL for image-uploader component - * - * @param OpenDialogUrl $subject - * @param array $itemName - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterGetData($subject, array $itemName) - { - if ($this->config->isEnabled()) { - $itemName['openDialogUrl'] = $this->url->getUrl('media_gallery/index/index'); - } - return $itemName; - } -} diff --git a/MediaGalleryIntegration/etc/adminhtml/di.xml b/MediaGalleryIntegration/etc/adminhtml/di.xml index be573fb88398..8d6f13b9e048 100644 --- a/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -12,7 +12,4 @@ - - - From d5d922ced4de73f3a249786921757da1ca109a12 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Tue, 14 Apr 2020 14:40:11 +0300 Subject: [PATCH 04/13] Add new media Gallery url to page builder --- MediaGalleryUi/etc/adminhtml/di.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MediaGalleryUi/etc/adminhtml/di.xml b/MediaGalleryUi/etc/adminhtml/di.xml index 0ee1de2210c5..f79fe38aa0c0 100644 --- a/MediaGalleryUi/etc/adminhtml/di.xml +++ b/MediaGalleryUi/etc/adminhtml/di.xml @@ -11,6 +11,13 @@ media + + + + media_gallery/index/index + + + From a2c42b32e36ae4a41f93c5007fa8546c1411d89c Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Tue, 14 Apr 2020 14:42:21 +0300 Subject: [PATCH 05/13] move di configuration to MediaGlleryIntegration module --- MediaGalleryIntegration/etc/adminhtml/di.xml | 7 +++++++ MediaGalleryUi/etc/adminhtml/di.xml | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MediaGalleryIntegration/etc/adminhtml/di.xml b/MediaGalleryIntegration/etc/adminhtml/di.xml index 8d6f13b9e048..802fe81502bf 100644 --- a/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -12,4 +12,11 @@ + + + + media_gallery/index/index + + + diff --git a/MediaGalleryUi/etc/adminhtml/di.xml b/MediaGalleryUi/etc/adminhtml/di.xml index f79fe38aa0c0..0ee1de2210c5 100644 --- a/MediaGalleryUi/etc/adminhtml/di.xml +++ b/MediaGalleryUi/etc/adminhtml/di.xml @@ -11,13 +11,6 @@ media - - - - media_gallery/index/index - - - From 96648c5238c1e47752cffaf019d795fd48ea52c1 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Wed, 15 Apr 2020 14:05:29 +0300 Subject: [PATCH 06/13] remove plugin as now we have one entry point --- .../Plugin/UpdateOpenDialogUrl.php | 56 ------------------- MediaGalleryIntegration/etc/adminhtml/di.xml | 9 +-- .../Ui/Component/Listing/Columns/Url.php | 2 +- 3 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 MediaGalleryIntegration/Plugin/UpdateOpenDialogUrl.php diff --git a/MediaGalleryIntegration/Plugin/UpdateOpenDialogUrl.php b/MediaGalleryIntegration/Plugin/UpdateOpenDialogUrl.php deleted file mode 100644 index 42be3a2a2415..000000000000 --- a/MediaGalleryIntegration/Plugin/UpdateOpenDialogUrl.php +++ /dev/null @@ -1,56 +0,0 @@ -url = $url; - $this->config = $config; - } - - /** - * Update open media gallery dialog URL for image-uploader component - * - * @param Image $component - */ - public function afterPrepare(Image $component): void - { - if (!$this->config->isEnabled()) { - return; - } - - $data = $component->getData(); - - $data['config']['mediaGallery']['openDialogUrl'] = $this->url->getUrl('media_gallery/index/index'); - - $component->setData($data); - } -} diff --git a/MediaGalleryIntegration/etc/adminhtml/di.xml b/MediaGalleryIntegration/etc/adminhtml/di.xml index 8d4c0454f381..a476a7dded05 100644 --- a/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -6,17 +6,12 @@ */ --> - - - - + - - media_gallery/index/index - + media_gallery/index/index diff --git a/MediaGalleryUi/Ui/Component/Listing/Columns/Url.php b/MediaGalleryUi/Ui/Component/Listing/Columns/Url.php index c03cc0ce64ca..bf024af16fee 100644 --- a/MediaGalleryUi/Ui/Component/Listing/Columns/Url.php +++ b/MediaGalleryUi/Ui/Component/Listing/Columns/Url.php @@ -71,7 +71,7 @@ public function prepareDataSource(array $dataSource): array { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { - $item['encoded_id'] = $this->images->idEncode($item['name']); + $item['encoded_id'] = $this->images->idEncode($item['path']); $item[$this->getData('name')] = $this->getUrl($item[$this->getData('name')]); } } From 48ab1495e4d1232aacb896252fe8f4be1d8e3172 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Wed, 15 Apr 2020 15:38:59 +0300 Subject: [PATCH 07/13] Add dependency to MagentoUi Module --- .../Plugin/UpdateWysiwygDialogUrlTinyMce.php | 59 ------------- .../Plugin/UpdateWysiwygOpenDialogUrl.php | 73 ---------------- .../Unit/Plugin/UpdateOpenDialogUrlTest.php | 87 ------------------- MediaGalleryIntegration/composer.json | 6 +- MediaGalleryIntegration/etc/adminhtml/di.xml | 8 +- MediaGalleryIntegration/etc/module.xml | 6 +- 6 files changed, 7 insertions(+), 232 deletions(-) delete mode 100644 MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php delete mode 100644 MediaGalleryIntegration/Plugin/UpdateWysiwygOpenDialogUrl.php delete mode 100644 MediaGalleryIntegration/Test/Unit/Plugin/UpdateOpenDialogUrlTest.php diff --git a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php b/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php deleted file mode 100644 index 0683c230e4b8..000000000000 --- a/MediaGalleryIntegration/Plugin/UpdateWysiwygDialogUrlTinyMce.php +++ /dev/null @@ -1,59 +0,0 @@ -url = $url; - $this->config = $config; - } - - /** - * Update open media gallery dialog URL for wysiwyg instance - * - * @param Config $subject - * @param DataObject $config - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterGetConfig(Config $subject, DataObject $config): DataObject - { - if (!$this->config->isEnabled()) { - return $config; - } - - $config->setData('files_browser_window_url', $this->url->getUrl('media_gallery/index/index')); - - return $config; - } -} diff --git a/MediaGalleryIntegration/Plugin/UpdateWysiwygOpenDialogUrl.php b/MediaGalleryIntegration/Plugin/UpdateWysiwygOpenDialogUrl.php deleted file mode 100644 index f06338290d56..000000000000 --- a/MediaGalleryIntegration/Plugin/UpdateWysiwygOpenDialogUrl.php +++ /dev/null @@ -1,73 +0,0 @@ -url = $url; - $this->imagesHelper = $imagesHelper; - $this->config = $config; - } - - /** - * Update open media gallery dialog URL for WYSIWYG - * - * @param DefaultConfigProvider $provider - * @param DataObject $config - * @return DataObject - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterGetConfig(DefaultConfigProvider $provider, DataObject $config): DataObject - { - if (!$this->config->isEnabled()) { - return $config; - } - - return $config->setData( - 'files_browser_window_url', - $this->url->getUrl( - 'media_gallery/index/index', - [ - 'current_tree_path' => $this->imagesHelper->idEncode(Config::IMAGE_DIRECTORY) - ] - ) - ); - } -} diff --git a/MediaGalleryIntegration/Test/Unit/Plugin/UpdateOpenDialogUrlTest.php b/MediaGalleryIntegration/Test/Unit/Plugin/UpdateOpenDialogUrlTest.php deleted file mode 100644 index bacb31f011f8..000000000000 --- a/MediaGalleryIntegration/Test/Unit/Plugin/UpdateOpenDialogUrlTest.php +++ /dev/null @@ -1,87 +0,0 @@ -imageComponentMock = $this->createMock(Image::class); - $this->urlMock = $this->getMockBuilder(UrlInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getUrl']) - ->getMockForAbstractClass(); - $this->configMock = $this->getMockBuilder(ConfigInterface::class) - ->disableOriginalConstructor() - ->setMethods(['isEnabled']) - ->getMockForAbstractClass(); - - $this->plugin = (new ObjectManagerHelper($this))->getObject( - UpdateOpenDialogUrl::class, - ['url' => $this->urlMock, 'config' => $this->configMock] - ); - } - - /** - * Test case with disabled config. - */ - public function testAfterPrepareWhenConfigDisabled(): void - { - $this->configMock->expects($this->once())->method('isEnabled')->willReturn(false); - $this->imageComponentMock->expects($this->never())->method('setData'); - $this->urlMock->expects($this->never())->method('getUrl'); - - $this->plugin->afterPrepare($this->imageComponentMock); - } - - /** - * Test case with enabled config, expects that url will be set to the Image component. - */ - public function testAfterPrepareExpectsSetDataCalled(): void - { - $this->configMock->expects($this->once())->method('isEnabled')->willReturn(true); - $this->urlMock->expects($this->once())->method('getUrl')->with('media_gallery/index/index'); - $this->imageComponentMock->expects($this->once())->method('setData'); - - $this->plugin->afterPrepare($this->imageComponentMock); - } -} diff --git a/MediaGalleryIntegration/composer.json b/MediaGalleryIntegration/composer.json index f568bf946280..03c1bc897f73 100644 --- a/MediaGalleryIntegration/composer.json +++ b/MediaGalleryIntegration/composer.json @@ -4,11 +4,7 @@ "require": { "php": "~7.1.3||~7.2.0||~7.3.0", "magento/framework": "*", - "magento/module-ui": "*", - "magento/module-media-gallery-ui-api": "*", - "magento/module-media-gallery-ui": "*", - "magento/module-cms": "*", - "magento/module-tinymce-3": "*" + "magento/module-ui": "*" }, "type": "magento2-module", "license": [ diff --git a/MediaGalleryIntegration/etc/adminhtml/di.xml b/MediaGalleryIntegration/etc/adminhtml/di.xml index a476a7dded05..b1cb92091457 100644 --- a/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -6,15 +6,9 @@ */ --> - - - - media_gallery/index/index + media_gallery/index/index - - - diff --git a/MediaGalleryIntegration/etc/module.xml b/MediaGalleryIntegration/etc/module.xml index f83275e7d07f..88af90477cc8 100644 --- a/MediaGalleryIntegration/etc/module.xml +++ b/MediaGalleryIntegration/etc/module.xml @@ -6,5 +6,9 @@ */ --> - + + + + + From 24d19333c4c56750f54ab7ea2cbd6af603a458bb Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Wed, 15 Apr 2020 18:14:04 +0300 Subject: [PATCH 08/13] remove tests --- .../Plugin/UpdateWysiwygOpenDialogUrlTest.php | 118 ------------------ 1 file changed, 118 deletions(-) delete mode 100644 MediaGalleryIntegration/Test/Unit/Plugin/UpdateWysiwygOpenDialogUrlTest.php diff --git a/MediaGalleryIntegration/Test/Unit/Plugin/UpdateWysiwygOpenDialogUrlTest.php b/MediaGalleryIntegration/Test/Unit/Plugin/UpdateWysiwygOpenDialogUrlTest.php deleted file mode 100644 index 7b342b33b8e0..000000000000 --- a/MediaGalleryIntegration/Test/Unit/Plugin/UpdateWysiwygOpenDialogUrlTest.php +++ /dev/null @@ -1,118 +0,0 @@ -defaultConfigProviderMock = $this->createMock(DefaultConfigProvider::class); - $this->configDataObjectMock = $this->createMock(DataObject::class); - - $this->urlMock = $this->getMockBuilder(UrlInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getUrl']) - ->getMockForAbstractClass(); - $this->configMock = $this->getMockBuilder(ConfigInterface::class) - ->disableOriginalConstructor() - ->setMethods(['isEnabled']) - ->getMockForAbstractClass(); - $this->imagesHelperMock = $this->createMock(Images::class); - - $this->plugin = (new ObjectManagerHelper($this))->getObject( - UpdateWysiwygOpenDialogUrl::class, - [ - 'url' => $this->urlMock, - 'imagesHelper' => $this->imagesHelperMock, - 'config' => $this->configMock - ] - ); - } - - /** - * Test case with disabled config. - */ - public function testAfterGetConfigWhenConfigDisabled(): void - { - $this->configMock->expects($this->once())->method('isEnabled')->willReturn(false); - $this->configDataObjectMock->expects($this->never())->method('setData'); - - $this->assertSame( - $this->configDataObjectMock, - $this->plugin->afterGetConfig($this->defaultConfigProviderMock, $this->configDataObjectMock) - ); - } - - /** - * Test case with enabled config, expects that url will be set to Config data object. - */ - public function testAfterGetConfigExpectsSetDataCalled(): void - { - $this->configMock->expects($this->once())->method('isEnabled')->willReturn(true); - $this->imagesHelperMock->expects($this->once())->method('idEncode')->with(Config::IMAGE_DIRECTORY); - $this->urlMock->expects($this->once())->method('getUrl')->willReturn(self::STUB_WINDOW_URL); - $this->configDataObjectMock->expects($this->once()) - ->method('setData') - ->with('files_browser_window_url', self::STUB_WINDOW_URL) - ->willReturnSelf(); - - $this->assertSame( - $this->configDataObjectMock, - $this->plugin->afterGetConfig($this->defaultConfigProviderMock, $this->configDataObjectMock) - ); - } -} From 7803d7fd129b7a4d9417a641f3fd005d7adf2a84 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Wed, 15 Apr 2020 18:29:21 +0300 Subject: [PATCH 09/13] remove redundant dependency --- MediaGalleryIntegration/composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MediaGalleryIntegration/composer.json b/MediaGalleryIntegration/composer.json index 03c1bc897f73..db7bd540695a 100644 --- a/MediaGalleryIntegration/composer.json +++ b/MediaGalleryIntegration/composer.json @@ -3,8 +3,7 @@ "description": "Magento module responsible for integration of enhanced media gallery", "require": { "php": "~7.1.3||~7.2.0||~7.3.0", - "magento/framework": "*", - "magento/module-ui": "*" + "magento/framework": "*" }, "type": "magento2-module", "license": [ From bf965cbec8464ff7afd2c37d046fcbc10e072458 Mon Sep 17 00:00:00 2001 From: Slava Mankivski Date: Wed, 15 Apr 2020 20:42:45 -0500 Subject: [PATCH 10/13] Update composer.json --- MediaGalleryIntegration/composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/MediaGalleryIntegration/composer.json b/MediaGalleryIntegration/composer.json index 8a7facf98778..db7bd540695a 100644 --- a/MediaGalleryIntegration/composer.json +++ b/MediaGalleryIntegration/composer.json @@ -5,9 +5,6 @@ "php": "~7.1.3||~7.2.0||~7.3.0", "magento/framework": "*" }, - "suggest": { - "magento/module-page-builder": "*" - }, "type": "magento2-module", "license": [ "OSL-3.0", From 7d1df48c8c947ca586c36ea60aaf04443fc52bc9 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 16 Apr 2020 09:22:20 +0300 Subject: [PATCH 11/13] Cover case with configuration media gallery disabled - enabled --- .../Model/OpenDialogUrlProvider.php | 44 +++++++++++++++++++ MediaGalleryIntegration/etc/adminhtml/di.xml | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 MediaGalleryIntegration/Model/OpenDialogUrlProvider.php diff --git a/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php b/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php new file mode 100644 index 000000000000..f22916ef3d95 --- /dev/null +++ b/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php @@ -0,0 +1,44 @@ +config = $config; + } + + /** + * Update open media gallery dialog URL for WYSIWYG + * + * @return DataObject + */ + public function getUrl(): string + { + if ($this->config->isEnabled()) { + return 'media_gallery/index/index'; + } + + return 'cms/wysiwyg_images/index'; + } +} diff --git a/MediaGalleryIntegration/etc/adminhtml/di.xml b/MediaGalleryIntegration/etc/adminhtml/di.xml index b1cb92091457..dc39059821a0 100644 --- a/MediaGalleryIntegration/etc/adminhtml/di.xml +++ b/MediaGalleryIntegration/etc/adminhtml/di.xml @@ -8,7 +8,7 @@ - media_gallery/index/index + Magento\MediaGalleryIntegration\Model\OpenDialogUrlProvider From c7ad77f0c37e6f33f1491340b5aa684b4db5bd75 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 16 Apr 2020 09:29:12 +0300 Subject: [PATCH 12/13] Add dependency --- MediaGalleryIntegration/Model/OpenDialogUrlProvider.php | 4 ++-- MediaGalleryIntegration/composer.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php b/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php index f22916ef3d95..ba797e7097e7 100644 --- a/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php +++ b/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php @@ -11,7 +11,7 @@ use Magento\Framework\DataObject; /** - * Plugin to update open media gallery dialog URL for WYSIWYG + * Provider to get open media gallery dialog URL for WYSIWYG and widgets */ class OpenDialogUrlProvider extends DataObject { @@ -29,7 +29,7 @@ public function __construct(ConfigInterface $config) } /** - * Update open media gallery dialog URL for WYSIWYG + * Get Url based on media gallery configuration * * @return DataObject */ diff --git a/MediaGalleryIntegration/composer.json b/MediaGalleryIntegration/composer.json index db7bd540695a..29e4a3561a68 100644 --- a/MediaGalleryIntegration/composer.json +++ b/MediaGalleryIntegration/composer.json @@ -3,7 +3,8 @@ "description": "Magento module responsible for integration of enhanced media gallery", "require": { "php": "~7.1.3||~7.2.0||~7.3.0", - "magento/framework": "*" + "magento/framework": "*", + "magento/module-media-gallery-ui-api": "*" }, "type": "magento2-module", "license": [ From fa93dee1f03ec75dd135961635047d94f28a1967 Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Thu, 16 Apr 2020 09:52:47 +0300 Subject: [PATCH 13/13] refactor per review comments --- MediaGalleryIntegration/Model/OpenDialogUrlProvider.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php b/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php index ba797e7097e7..9762c2a2aaf0 100644 --- a/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php +++ b/MediaGalleryIntegration/Model/OpenDialogUrlProvider.php @@ -31,14 +31,10 @@ public function __construct(ConfigInterface $config) /** * Get Url based on media gallery configuration * - * @return DataObject + * @return string */ public function getUrl(): string { - if ($this->config->isEnabled()) { - return 'media_gallery/index/index'; - } - - return 'cms/wysiwyg_images/index'; + return $this->config->isEnabled() ? 'media_gallery/index/index' : 'cms/wysiwyg_images/index'; } }