Skip to content

Commit 62a0b19

Browse files
committed
Remove hardcoded url, use default config url instead
1 parent 1605bd0 commit 62a0b19

File tree

3 files changed

+57
-10
lines changed

3 files changed

+57
-10
lines changed

app/code/Magento/PageBuilder/Model/Config/ContentType/AdditionalData/Provider/Uploader/OpenDialogUrl.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@
99
namespace Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader;
1010

1111
use Magento\PageBuilder\Model\Config\ContentType\AdditionalData\ProviderInterface;
12-
use Magento\Backend\Model\Url;
12+
use Magento\Framework\FlagManager;
1313

1414
/**
1515
* Provides open dialog URL for media gallery slideout
1616
*/
1717
class OpenDialogUrl implements ProviderInterface
1818
{
19+
private const MEDIA_GALLERY_OPEN_URL = 'open_dialog_url';
20+
1921
/**
20-
* @var Url
22+
* @var FlagManager
2123
*/
22-
private $urlBuilder;
24+
private $scopeConfig;
2325

2426
/**
2527
* @param Url $urlBuilder
2628
*/
27-
public function __construct(Url $urlBuilder)
28-
{
29-
$this->urlBuilder = $urlBuilder;
29+
public function __construct(
30+
FlagManager $scopeConfig
31+
) {
32+
$this->scopeConfig = $scopeConfig;
3033
}
3134

3235
/**
@@ -35,10 +38,7 @@ public function __construct(Url $urlBuilder)
3538
public function getData(string $itemName) : array
3639
{
3740
return [
38-
$itemName => $this->urlBuilder->getUrl(
39-
'cms/wysiwyg_images/index',
40-
['_secure' => true]
41-
)
41+
$itemName => $this->scopeConfig->getFlagData(self::MEDIA_GALLERY_OPEN_URL)
4242
];
4343
}
4444
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\PageBuilder\Plugin;
9+
10+
use Magento\Ui\Component\Form\Element\DataType\Media\Image;
11+
use Magento\Framework\FlagManager;
12+
13+
/**
14+
* Plugin to set open media gallery dialog URL
15+
*/
16+
class SetOpenDialogUrl
17+
{
18+
private const MEDIA_GALLERY_OPEN_URL = 'open_dialog_url';
19+
20+
/**
21+
* @var FlagManager
22+
*/
23+
private $config;
24+
25+
/**
26+
* @param FlagManager $config
27+
*/
28+
public function __construct(FlagManager $config)
29+
{
30+
$this->config = $config;
31+
}
32+
33+
/**
34+
* Set open media gallery dialog URL for image-uploader component
35+
*
36+
* @param Image $component
37+
*/
38+
public function afterPrepare(Image $component): void
39+
{
40+
$data = $component->getData();
41+
42+
$this->config->saveFlag(self::MEDIA_GALLERY_OPEN_URL, $data['config']['mediaGallery']['openDialogUrl']);
43+
}
44+
}

app/code/Magento/PageBuilder/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<type name="Magento\Catalog\Block\Product\ImageFactory">
1313
<plugin name="designLoader" type="Magento\PageBuilder\Plugin\DesignLoader" />
1414
</type>
15+
<type name="Magento\Ui\Component\Form\Element\DataType\Media\Image">
16+
<plugin name="setOpenDialogUrl" type="Magento\PageBuilder\Plugin\SetOpenDialogUrl"/>
17+
</type>
1518
<virtualType name="Magento\PageBuilder\Block\Adminhtml\ContentType\Edit\ModalCloseButton" type="Magento\PageBuilder\Block\Adminhtml\ContentType\Edit\CloseButton">
1619
<arguments>
1720
<argument name="targetName" xsi:type="string">ns = pagebuilder_modal_form, index = modal</argument>

0 commit comments

Comments
 (0)