Contact.php 2.2 KB

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