Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TestConnection.php
Go to the documentation of this file.
1 <?php
7 
13 class TestConnection extends \Magento\Config\Block\System\Config\Form\Field
14 {
21  protected function _prepareLayout()
22  {
23  parent::_prepareLayout();
24  $this->setTemplate('Magento_AdvancedSearch::system/config/testconnection.phtml');
25  return $this;
26  }
27 
35  public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
36  {
37  $element = clone $element;
38  $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
39  return parent::render($element);
40  }
41 
49  protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
50  {
51  $originalData = $element->getOriginalData();
52  $this->addData(
53  [
54  'button_label' => __($originalData['button_label']),
55  'html_id' => $element->getHtmlId(),
56  'ajax_url' => $this->_urlBuilder->getUrl('catalog/search_system_config/testconnection'),
57  'field_mapping' => str_replace('"', '\\"', json_encode($this->_getFieldMapping()))
58  ]
59  );
60 
61  return $this->_toHtml();
62  }
63 
70  protected function _getFieldMapping()
71  {
72  return ['engine' => 'catalog_search_engine'];
73  }
74 }
__()
Definition: __.php:13
_getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
$element
Definition: element.phtml:12