Reviewsync.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Dotdigitalgroup\Email\Block\Adminhtml\Config\Developer;
  3. class Reviewsync 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. $url = $this->_urlBuilder->getUrl('dotdigitalgroup_email/run/reviewsync');
  30. return $this->getLayout()
  31. ->createBlock(\Magento\Backend\Block\Widget\Button::class)
  32. ->setType('button')
  33. ->setLabel($this->buttonLabel)
  34. ->setOnClick("window.location.href='" . $url . "'")
  35. ->toHtml();
  36. }
  37. }