Review.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace Dotdigitalgroup\Email\Block\Adminhtml\Config\Report;
  3. class Review extends \Magento\Config\Block\System\Config\Form\Field
  4. {
  5. /**
  6. * @deprecated
  7. *
  8. * @var string
  9. */
  10. public $buttonLabel = 'Review Report';
  11. /**
  12. * @deprecated
  13. *
  14. * @param string $buttonLabel
  15. *
  16. * @return $this
  17. */
  18. public function setButtonLabel($buttonLabel)
  19. {
  20. $this->buttonLabel = $buttonLabel;
  21. return $this;
  22. }
  23. /**
  24. * Set template to itself.
  25. *
  26. * @deprecated
  27. *
  28. * @return mixed
  29. */
  30. public function _prepareLayout()
  31. {
  32. parent::_prepareLayout();
  33. if (!$this->getTemplate()) {
  34. $this->setTemplate('system/config/reportlink.phtml');
  35. }
  36. return $this;
  37. }
  38. /**
  39. * @deprecated
  40. *
  41. * @return string
  42. */
  43. public function getLink()
  44. {
  45. return $this->getUrl(
  46. 'dotdigitalgroup_email/review/index'
  47. );
  48. }
  49. /**
  50. * Unset some non-related element parameters.
  51. *
  52. * @deprecated
  53. *
  54. * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  55. *
  56. * @return string
  57. */
  58. public function render(
  59. \Magento\Framework\Data\Form\Element\AbstractElement $element
  60. )
  61. {
  62. $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
  63. return parent::render($element);
  64. }
  65. /**
  66. * Get the button and scripts contents.
  67. *
  68. * @deprecated
  69. *
  70. * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  71. *
  72. * @return string
  73. */
  74. public function _getElementHtml(
  75. \Magento\Framework\Data\Form\Element\AbstractElement $element
  76. )
  77. {
  78. $originalData = $element->getOriginalData();
  79. $buttonLabel = !empty($originalData['button_label'])
  80. ? $originalData['button_label'] : $this->buttonLabel;
  81. $url
  82. = $this->_urlBuilder->getUrl('dotdigitalgroup_email/addressbook/save');
  83. $this->addData(
  84. [
  85. 'button_label' => $buttonLabel,
  86. 'html_id' => $element->getHtmlId(),
  87. 'ajax_url' => $url,
  88. ]
  89. );
  90. return $this->_toHtml();
  91. }
  92. }