Edit.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\System\Design;
  7. class Edit extends \Magento\Backend\Block\Widget
  8. {
  9. /**
  10. * @var string
  11. */
  12. protected $_template = 'Magento_Backend::system/design/edit.phtml';
  13. /**
  14. * Core registry
  15. *
  16. * @var \Magento\Framework\Registry
  17. */
  18. protected $_coreRegistry = null;
  19. /**
  20. * @param \Magento\Backend\Block\Template\Context $context
  21. * @param \Magento\Framework\Registry $registry
  22. * @param array $data
  23. */
  24. public function __construct(
  25. \Magento\Backend\Block\Template\Context $context,
  26. \Magento\Framework\Registry $registry,
  27. array $data = []
  28. ) {
  29. $this->_coreRegistry = $registry;
  30. parent::__construct($context, $data);
  31. }
  32. /**
  33. * @return void
  34. */
  35. protected function _construct()
  36. {
  37. parent::_construct();
  38. $this->setId('design_edit');
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. protected function _prepareLayout()
  44. {
  45. $this->getToolbar()->addChild(
  46. 'back_button',
  47. \Magento\Backend\Block\Widget\Button::class,
  48. [
  49. 'label' => __('Back'),
  50. 'onclick' => 'setLocation(\'' . $this->getUrl('adminhtml/*/') . '\')',
  51. 'class' => 'back'
  52. ]
  53. );
  54. if ($this->getDesignChangeId()) {
  55. $this->getToolbar()->addChild(
  56. 'delete_button',
  57. \Magento\Backend\Block\Widget\Button::class,
  58. [
  59. 'label' => __('Delete'),
  60. 'onclick' => 'deleteConfirm(\'' . __(
  61. 'Are you sure?'
  62. ) . '\', \'' . $this->getDeleteUrl() . '\')',
  63. 'class' => 'delete'
  64. ]
  65. );
  66. }
  67. $this->getToolbar()->addChild(
  68. 'save_button',
  69. \Magento\Backend\Block\Widget\Button::class,
  70. [
  71. 'label' => __('Save'),
  72. 'class' => 'save primary',
  73. 'data_attribute' => [
  74. 'mage-init' => ['button' => ['event' => 'save', 'target' => '#design-edit-form']],
  75. ]
  76. ]
  77. );
  78. return parent::_prepareLayout();
  79. }
  80. /**
  81. * @return string
  82. */
  83. public function getDesignChangeId()
  84. {
  85. return $this->_coreRegistry->registry('design')->getId();
  86. }
  87. /**
  88. * @return string
  89. */
  90. public function getDeleteUrl()
  91. {
  92. return $this->getUrl('adminhtml/*/delete', ['_current' => true]);
  93. }
  94. /**
  95. * @return string
  96. */
  97. public function getSaveUrl()
  98. {
  99. return $this->getUrl('adminhtml/*/save', ['_current' => true]);
  100. }
  101. /**
  102. * @return string
  103. */
  104. public function getValidationUrl()
  105. {
  106. return $this->getUrl('adminhtml/*/validate', ['_current' => true]);
  107. }
  108. /**
  109. * @return string
  110. */
  111. public function getHeader()
  112. {
  113. if ($this->_coreRegistry->registry('design')->getId()) {
  114. $header = __('Edit Design Change');
  115. } else {
  116. $header = __('New Store Design Change');
  117. }
  118. return $header;
  119. }
  120. }