@@ -13,17 +13,25 @@ class OnInsert extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
13
13
*/
14
14
protected $ resultRawFactory ;
15
15
16
+ /**
17
+ * @var \Magento\Cms\Model\Wysiwyg\Images\PrepareImage
18
+ */
19
+ protected $ prepareImage ;
20
+
16
21
/**
17
22
* @param \Magento\Backend\App\Action\Context $context
18
23
* @param \Magento\Framework\Registry $coreRegistry
19
24
* @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
25
+ * @param \Magento\Cms\Model\Wysiwyg\Images\PrepareImage $prepareImage
20
26
*/
21
27
public function __construct (
22
28
\Magento \Backend \App \Action \Context $ context ,
23
29
\Magento \Framework \Registry $ coreRegistry ,
24
- \Magento \Framework \Controller \Result \RawFactory $ resultRawFactory
30
+ \Magento \Framework \Controller \Result \RawFactory $ resultRawFactory ,
31
+ \Magento \Cms \Model \Wysiwyg \Images \PrepareImage $ prepareImage
25
32
) {
26
33
$ this ->resultRawFactory = $ resultRawFactory ;
34
+ $ this ->prepareImage = $ prepareImage ;
27
35
parent ::__construct ($ context , $ coreRegistry );
28
36
}
29
37
@@ -34,26 +42,10 @@ public function __construct(
34
42
*/
35
43
public function execute ()
36
44
{
37
- $ imagesHelper = $ this ->_objectManager ->get (\Magento \Cms \Helper \Wysiwyg \Images::class);
38
45
$ request = $ this ->getRequest ();
39
46
40
- $ storeId = $ request ->getParam ('store ' );
41
-
42
- $ filename = $ request ->getParam ('filename ' );
43
- $ filename = $ imagesHelper ->idDecode ($ filename );
44
-
45
- $ asIs = $ request ->getParam ('as_is ' );
46
-
47
- $ forceStaticPath = $ request ->getParam ('force_static_path ' );
48
-
49
- $ this ->_objectManager ->get (\Magento \Catalog \Helper \Data::class)->setStoreId ($ storeId );
50
- $ imagesHelper ->setStoreId ($ storeId );
51
-
52
- if ($ forceStaticPath ) {
53
- $ image = parse_url ($ imagesHelper ->getCurrentUrl () . $ filename , PHP_URL_PATH );
54
- } else {
55
- $ image = $ imagesHelper ->getImageHtmlDeclaration ($ filename , $ asIs );
56
- }
47
+ /** @var \Magento\Cms\Model\Wysiwyg\Images\PrepareImage $image */
48
+ $ image = $ this ->prepareImage ->execute ($ request ->getParams ());
57
49
58
50
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
59
51
$ resultRaw = $ this ->resultRawFactory ->create ();
0 commit comments