Delete.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\System\Store;
  7. /**
  8. * Store / store view / website delete form container
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. class Delete extends \Magento\Backend\Block\Widget\Form\Container
  13. {
  14. /**
  15. * Class constructor
  16. *
  17. * @return void
  18. */
  19. protected function _construct()
  20. {
  21. $this->_objectId = 'item_id';
  22. $this->_mode = 'delete';
  23. $this->_blockGroup = 'Magento_Backend';
  24. $this->_controller = 'system_store';
  25. parent::_construct();
  26. $this->buttonList->remove('save');
  27. $this->buttonList->remove('reset');
  28. $this->buttonList->update('delete', 'region', 'toolbar');
  29. $this->buttonList->update('delete', 'onclick', null);
  30. $this->buttonList->update(
  31. 'delete',
  32. 'data_attribute',
  33. ['mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']]]
  34. );
  35. $this->buttonList->add(
  36. 'cancel',
  37. ['label' => __('Cancel'), 'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')'],
  38. 2,
  39. 100,
  40. 'toolbar'
  41. );
  42. }
  43. /**
  44. * Get edit form container header text
  45. *
  46. * @return \Magento\Framework\Phrase
  47. */
  48. public function getHeaderText()
  49. {
  50. return __(
  51. "Delete %1 '%2'",
  52. $this->getStoreTypeTitle(),
  53. $this->escapeHtml($this->getChildBlock('form')->getDataObject()->getName())
  54. );
  55. }
  56. /**
  57. * Set store type title
  58. *
  59. * @param string $title
  60. * @return $this
  61. */
  62. public function setStoreTypeTitle($title)
  63. {
  64. $this->buttonList->update('delete', 'label', __('Delete %1', $title));
  65. return $this->setData('store_type_title', $title);
  66. }
  67. /**
  68. * Set back URL for "Cancel" and "Back" buttons
  69. *
  70. * @param string $url
  71. * @return $this
  72. */
  73. public function setBackUrl($url)
  74. {
  75. $this->setData('back_url', $url);
  76. $this->buttonList->update('cancel', 'onclick', "setLocation('" . $url . "')");
  77. $this->buttonList->update('back', 'onclick', "setLocation('" . $url . "')");
  78. return $this;
  79. }
  80. }