Button.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Mageplaza
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Mageplaza.com license that is
  8. * available through the world-wide-web at this URL:
  9. * https://www.mageplaza.com/LICENSE.txt
  10. *
  11. * DISCLAIMER
  12. *
  13. * Do not edit or add to this file if you wish to upgrade this extension to newer
  14. * version in the future.
  15. *
  16. * @category Mageplaza
  17. * @package Mageplaza_Search
  18. * @copyright Copyright (c) 2017 Mageplaza (http://www.mageplaza.com/)
  19. * @license https://www.mageplaza.com/LICENSE.txt
  20. */
  21. namespace Mageplaza\Search\Block\Adminhtml\System\Config;
  22. use Magento\Config\Block\System\Config\Form\Field;
  23. /**
  24. * Class Button
  25. * @package Magento\Paypal\Block\Adminhtml\System\Config
  26. */
  27. class Button extends Field
  28. {
  29. /**
  30. * @var string
  31. */
  32. protected $_template = 'system/config/button.phtml';
  33. /**
  34. * Unset scope
  35. *
  36. * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  37. * @return string
  38. */
  39. public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
  40. {
  41. $element->unsScope();
  42. return parent::render($element);
  43. }
  44. /**
  45. * Get the button and scripts contents
  46. *
  47. * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  48. * @return string
  49. */
  50. protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
  51. {
  52. $originalData = $element->getOriginalData();
  53. $this->addData(
  54. [
  55. 'button_label' => __($originalData['button_label']),
  56. 'button_url' => $this->getUrl($originalData['button_url']),
  57. 'html_id' => $element->getHtmlId(),
  58. ]
  59. );
  60. return $this->_toHtml();
  61. }
  62. }