7
7
namespace Magento \CatalogRule \Controller \Adminhtml \Promo \Catalog ;
8
8
9
9
use Magento \CatalogRule \Controller \Adminhtml \Promo \Catalog as CatalogAction ;
10
+ use Magento \CatalogRule \Model \Rule ;
10
11
use Magento \Framework \App \Action \HttpGetActionInterface ;
11
12
use Magento \Framework \App \Action \HttpPostActionInterface as HttpPostActionInterface ;
12
13
use Magento \Rule \Model \Condition \AbstractCondition ;
@@ -21,34 +22,36 @@ class NewConditionHtml extends CatalogAction implements HttpPostActionInterface,
21
22
*/
22
23
public function execute ()
23
24
{
24
- $ id = $ this ->getRequest ()->getParam ('id ' );
25
- $ formName = $ this ->getRequest ()->getParam ('form_namespace ' );
26
- $ typeArr = explode ('| ' , str_replace ('- ' , '/ ' , $ this ->getRequest ()->getParam ('type ' , '' )));
27
- $ type = $ typeArr [0 ];
25
+ $ objectId = $ this ->getRequest ()->getParam ('id ' );
26
+ $ formNamespace = $ this ->getRequest ()->getParam ('form_namespace ' );
27
+ $ types = explode (
28
+ '| ' ,
29
+ str_replace ('- ' , '/ ' , $ this ->getRequest ()->getParam ('type ' , '' ))
30
+ );
31
+ $ objectType = $ types [0 ];
32
+ $ reponseBody = '' ;
28
33
29
- if (class_exists ($ type ) && !in_array (ConditionInterface::class, class_implements ($ type ))) {
30
- $ html = '' ;
31
- $ this ->getResponse ()->setBody ($ html );
34
+ if (class_exists ($ objectType ) && !in_array (ConditionInterface::class, class_implements ($ objectType ))) {
35
+ $ this ->getResponse ()->setBody ($ reponseBody );
32
36
return ;
33
37
}
34
38
35
- $ model = $ this ->_objectManager ->create ($ type )
36
- ->setId ($ id )
37
- ->setType ($ type )
38
- ->setRule ($ this ->_objectManager ->create (\ Magento \ CatalogRule \ Model \ Rule::class))
39
+ $ conditionModel = $ this ->_objectManager ->create ($ objectType )
40
+ ->setId ($ objectId )
41
+ ->setType ($ objectType )
42
+ ->setRule ($ this ->_objectManager ->create (Rule::class))
39
43
->setPrefix ('conditions ' );
40
44
41
- if (!empty ($ typeArr [1 ])) {
42
- $ model ->setAttribute ($ typeArr [1 ]);
45
+ if (!empty ($ types [1 ])) {
46
+ $ conditionModel ->setAttribute ($ types [1 ]);
43
47
}
44
48
45
- if ($ model instanceof AbstractCondition) {
46
- $ model ->setJsFormObject ($ this ->getRequest ()->getParam ('form ' ));
47
- $ model ->setFormName ($ formName );
48
- $ html = $ model ->asHtmlRecursive ();
49
- } else {
50
- $ html = '' ;
49
+ if ($ conditionModel instanceof AbstractCondition) {
50
+ $ conditionModel ->setJsFormObject ($ this ->getRequest ()->getParam ('form ' ));
51
+ $ conditionModel ->setFormName ($ formNamespace );
52
+ $ reponseBody = $ conditionModel ->asHtmlRecursive ();
51
53
}
52
- $ this ->getResponse ()->setBody ($ html );
54
+
55
+ $ this ->getResponse ()->setBody ($ reponseBody );
53
56
}
54
57
}
0 commit comments