NewActionHtml.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
  8. class NewActionHtml extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
  9. {
  10. /**
  11. * New action html action
  12. *
  13. * @return void
  14. */
  15. public function execute()
  16. {
  17. $id = $this->getRequest()->getParam('id');
  18. $formName = $this->getRequest()->getParam('form');
  19. $typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
  20. $type = $typeArr[0];
  21. $model = $this->_objectManager->create(
  22. $type
  23. )->setId(
  24. $id
  25. )->setType(
  26. $type
  27. )->setRule(
  28. $this->_objectManager->create(\Magento\SalesRule\Model\Rule::class)
  29. )->setPrefix(
  30. 'actions'
  31. );
  32. if (!empty($typeArr[1])) {
  33. $model->setAttribute($typeArr[1]);
  34. }
  35. if ($model instanceof \Magento\Rule\Model\Condition\AbstractCondition) {
  36. $model->setJsFormObject($formName);
  37. $html = $model->asHtmlRecursive();
  38. } else {
  39. $html = '';
  40. }
  41. $this->getResponse()->setBody($html);
  42. }
  43. }