Skip to content

Commit 67c2c0c

Browse files
committed
Improve opendialogurl configuration to be extensible
1 parent 985c679 commit 67c2c0c

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

app/code/Magento/Ui/Component/Form/Element/DataType/Media/Image.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,30 @@ class Image extends Media
3131
*/
3232
private $fileSize;
3333

34+
/**
35+
* @var OpednDialogUrl
36+
*/
37+
private $openDialogConfig;
38+
3439
/**
3540
* @param ContextInterface $context
3641
* @param StoreManagerInterface $storeManager
3742
* @param Size $fileSize
43+
* @param OpenDialogUrl $openDialogConfig
3844
* @param UiComponentInterface[] $components
3945
* @param array $data
4046
*/
4147
public function __construct(
4248
ContextInterface $context,
4349
StoreManagerInterface $storeManager,
4450
Size $fileSize,
51+
OpenDialogUrl $openDialogConfig,
4552
array $components = [],
4653
array $data = []
4754
) {
4855
$this->storeManager = $storeManager;
4956
$this->fileSize = $fileSize;
57+
$this->openDialogConfig = $openDialogConfig;
5058
parent::__construct($context, $components, $data);
5159
}
5260

@@ -75,7 +83,10 @@ public function prepare()
7583
'config' => [
7684
'maxFileSize' => $maxFileSize,
7785
'mediaGallery' => [
78-
'openDialogUrl' => $this->getContext()->getUrl('cms/wysiwyg_images/index', ['_secure' => true]),
86+
'openDialogUrl' => $this->getContext()->getUrl(
87+
$this->openDialogConfig->getOpenDialogUrl(),
88+
['_secure' => true]
89+
),
7990
'openDialogTitle' => $this->getConfiguration()['openDialogTitle'] ?? __('Insert Images...'),
8091
'initialOpenSubpath' => $this->getConfiguration()['initialMediaGalleryOpenSubpath'],
8192
'storeId' => $this->storeManager->getStore()->getId(),
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Ui\Component\Form\Element\DataType\Media;
10+
11+
/**
12+
* Basic configuration for OdenDialogUrl
13+
*/
14+
class OpenDialogUrl
15+
{
16+
private const DEFAULT_OPEN_DIALOG_URL = 'cms/wysiwyg_images/index';
17+
18+
/**
19+
* @var string
20+
*/
21+
private $openDialogUrl;
22+
23+
/**
24+
* @param string $openDialog
25+
*/
26+
public function __construct(string $openDialog = null)
27+
{
28+
$this->openDialogUrl = $openDialog ?? self::DEFAULT_OPEN_DIALOG_URL;
29+
}
30+
31+
/**
32+
* Returns open dialog url for media browser
33+
*/
34+
public function getOpenDialogUrl(): string
35+
{
36+
return $this->openDialogUrl;
37+
}
38+
}

0 commit comments

Comments
 (0)