Automapdatafields.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Dotdigitalgroup\Email\Block\Adminhtml\Config\Developer;
  3. class Automapdatafields extends \Magento\Config\Block\System\Config\Form\Field
  4. {
  5. /**
  6. * @var string
  7. */
  8. public $buttonLabel = 'Run Now';
  9. /**
  10. * @param string $buttonLabel
  11. *
  12. * @return $this
  13. */
  14. public function setButtonLabel($buttonLabel)
  15. {
  16. $this->buttonLabel = $buttonLabel;
  17. return $this;
  18. }
  19. /**
  20. * Get the button and scripts contents.
  21. *
  22. * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  23. *
  24. * @return string
  25. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  26. */
  27. public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
  28. {
  29. $website = $this->getRequest()->getParam('website', 0);
  30. $params = ['website' => $website];
  31. $url = $this->_urlBuilder->getUrl('dotdigitalgroup_email/run/automapdatafields', $params);
  32. return $this->getLayout()
  33. ->createBlock(\Magento\Backend\Block\Widget\Button::class)
  34. ->setType('button')
  35. ->setLabel($this->buttonLabel)
  36. ->setOnClick("window.location.href='" . $url . "'")
  37. ->toHtml();
  38. }
  39. }