123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- declare(strict_types=1);
- namespace Magento\Cms\Model\Wysiwyg\Gallery;
- class DefaultConfigProvider implements \Magento\Framework\Data\Wysiwyg\ConfigProviderInterface
- {
- /**
- * @var \Magento\Backend\Model\UrlInterface
- */
- private $backendUrl;
- /**
- * @var \Magento\Cms\Helper\Wysiwyg\Images
- */
- private $imagesHelper;
- /**
- * @var array
- */
- private $windowSize;
- /**
- * @var string|null
- */
- private $currentTreePath;
- /**
- * @param \Magento\Backend\Model\UrlInterface $backendUrl
- * @param \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper
- * @param array $windowSize
- * @param string|null $currentTreePath
- */
- public function __construct(
- \Magento\Backend\Model\UrlInterface $backendUrl,
- \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper,
- array $windowSize = [],
- $currentTreePath = null
- ) {
- $this->backendUrl = $backendUrl;
- $this->imagesHelper = $imagesHelper;
- $this->windowSize = $windowSize;
- $this->currentTreePath = $currentTreePath;
- }
- /**
- * {@inheritdoc}
- */
- public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
- {
- $pluginData = (array) $config->getData('plugins');
- $imageData = [
- [
- 'name' => 'image',
- ]
- ];
- $fileBrowserUrlParams = [];
- if (is_string($this->currentTreePath)) {
- $fileBrowserUrlParams = [
- 'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
- ];
- }
- return $config->addData(
- [
- 'add_images' => true,
- 'files_browser_window_url' => $this->backendUrl->getUrl(
- 'cms/wysiwyg_images/index',
- $fileBrowserUrlParams
- ),
- 'files_browser_window_width' => $this->windowSize['width'],
- 'files_browser_window_height' => $this->windowSize['height'],
- 'plugins' => array_merge($pluginData, $imageData)
- ]
- );
- }
- }
|