Edit.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Smartwave\Dailydeals\Block\Adminhtml\Dailydeal;
  3. class Edit extends \Magento\Backend\Block\Widget\Form\Container
  4. {
  5. /**
  6. * Core registry
  7. *
  8. * @var \Magento\Framework\Registry
  9. */
  10. protected $coreRegistry;
  11. /**
  12. * constructor
  13. *
  14. * @param \Magento\Framework\Registry $coreRegistry
  15. * @param \Magento\Backend\Block\Widget\Context $context
  16. * @param array $data
  17. */
  18. public function __construct(
  19. \Magento\Framework\Registry $coreRegistry,
  20. \Magento\Backend\Block\Widget\Context $context,
  21. array $data = []
  22. ) {
  23. $this->coreRegistry = $coreRegistry;
  24. parent::__construct($context, $data);
  25. }
  26. /**
  27. * Initialize Dailydeal edit block
  28. *
  29. * @return void
  30. */
  31. protected function _construct()
  32. {
  33. $this->_objectId = 'dailydeal_id';
  34. $this->_blockGroup = 'Smartwave_Dailydeals';
  35. $this->_controller = 'adminhtml_dailydeal';
  36. parent::_construct();
  37. $this->buttonList->update('save', 'label', __('Save Dailydeal'));
  38. $this->buttonList->add(
  39. 'save-and-continue',
  40. [
  41. 'label' => __('Save and Continue Edit'),
  42. 'class' => 'save',
  43. 'data_attribute' => [
  44. 'mage-init' => [
  45. 'button' => [
  46. 'event' => 'saveAndContinueEdit',
  47. 'target' => '#edit_form'
  48. ]
  49. ]
  50. ]
  51. ],
  52. -100
  53. );
  54. $this->buttonList->update('delete', 'label', __('Delete Dailydeal'));
  55. }
  56. /**
  57. * Retrieve text for header element depending on loaded Dailydeal
  58. *
  59. * @return string
  60. */
  61. public function getHeaderText()
  62. {
  63. /** @var \Smartwave\Dailydeals\Model\Dailydeal $dailydeal */
  64. $dailydeal = $this->coreRegistry->registry('sw_dailydeals_dailydeal');
  65. if ($dailydeal->getId()) {
  66. return __("Edit Dailydeal '%1'", $this->escapeHtml($dailydeal->getSw_product_sku()));
  67. }
  68. return __('New Dailydeal');
  69. }
  70. }