Skip to content

Commit 4d935b0

Browse files
committed
CABPI-458: [Bug] Magento issue with DI compilation on 2.4.5-alpha1
-- fix static failure
1 parent 0e5e382 commit 4d935b0

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/NewConditionHtml.php

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog;
88

99
use Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog as CatalogAction;
10+
use Magento\CatalogRule\Model\Rule;
1011
use Magento\Framework\App\Action\HttpGetActionInterface;
1112
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1213
use Magento\Rule\Model\Condition\AbstractCondition;
@@ -21,34 +22,36 @@ class NewConditionHtml extends CatalogAction implements HttpPostActionInterface,
2122
*/
2223
public function execute()
2324
{
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 = '';
2833

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);
3236
return;
3337
}
3438

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))
3943
->setPrefix('conditions');
4044

41-
if (!empty($typeArr[1])) {
42-
$model->setAttribute($typeArr[1]);
45+
if (!empty($types[1])) {
46+
$conditionModel->setAttribute($types[1]);
4347
}
4448

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();
5153
}
52-
$this->getResponse()->setBody($html);
54+
55+
$this->getResponse()->setBody($reponseBody);
5356
}
5457
}

0 commit comments

Comments
 (0)