Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefaultConfigProvider.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
10 
12 {
16  private $backendUrl;
17 
21  private $imagesHelper;
22 
26  private $windowSize;
27 
31  private $currentTreePath;
32 
39  public function __construct(
40  \Magento\Backend\Model\UrlInterface $backendUrl,
41  \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper,
42  array $windowSize = [],
43  $currentTreePath = null
44  ) {
45  $this->backendUrl = $backendUrl;
46  $this->imagesHelper = $imagesHelper;
47  $this->windowSize = $windowSize;
48  $this->currentTreePath = $currentTreePath;
49  }
50 
54  public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
55  {
56  $pluginData = (array) $config->getData('plugins');
57  $imageData = [
58  [
59  'name' => 'image',
60  ]
61  ];
62 
63  $fileBrowserUrlParams = [];
64 
65  if (is_string($this->currentTreePath)) {
66  $fileBrowserUrlParams = [
67  'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
68  ];
69  }
70 
71  return $config->addData(
72  [
73  'add_images' => true,
74  'files_browser_window_url' => $this->backendUrl->getUrl(
75  'cms/wysiwyg_images/index',
76  $fileBrowserUrlParams
77  ),
78  'files_browser_window_width' => $this->windowSize['width'],
79  'files_browser_window_height' => $this->windowSize['height'],
80  'plugins' => array_merge($pluginData, $imageData)
81  ]
82  );
83  }
84 }
$config
Definition: fraud_order.php:17