jsonEncoder = $jsonEncoder; $this->ruleValue = $ruleValue; $this->http = $http; $this->escaper = $escaper; parent::__construct($context); } /** * Execute method. * * @return null */ public function execute() { $response = []; $valueName = $this->getRequest()->getParam('value'); $conditionValue = $this->getRequest()->getParam('condValue'); $attributeValue = $this->getRequest()->getParam('attributeValue'); if ($valueName && $attributeValue && $conditionValue) { if ($conditionValue == 'null') { $valueOptions = $this->ruleValue->getValueSelectOptions($attributeValue, true); $response['cvalue'] = $this->getOptionHtml('cvalue', $valueName, $valueOptions); } else { $elmType = $this->ruleValue->getValueElementType($attributeValue); if ($elmType == 'select') { $valueOptions = $this->ruleValue->getValueSelectOptions($attributeValue); $response['cvalue'] = $this->getOptionHtml('cvalue', $valueName, $valueOptions); } elseif ($elmType == 'text') { $html = ""; $response['cvalue'] = $html; } } $this->http->getHeaders()->clearHeaders(); $this->http->setHeader('Content-Type', 'application/json')->setBody( $this->jsonEncoder->jsonEncode($response) ); } } /** * @param string $title * @param string $name * @param array $options * * @return string */ private function getOptionHtml($title, $name, $options) { $block = $this->_view->getLayout()->createBlock(\Magento\Framework\View\Element\Html\Select::class); $block->setOptions($options) ->setId('') ->setClass('') ->setTitle($title) ->setName($name) ->setExtraParams('style="width:160px"'); return $block->toHtml(); } }