Notice.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
  4. */
  5. namespace Temando\Shipping\Block\Adminhtml\Activation;
  6. use Magento\Backend\Block\Template;
  7. use Magento\Framework\Exception\LocalizedException;
  8. /**
  9. * Activation Notice Layout Block
  10. *
  11. * @package Temando\Shipping\Block
  12. * @author Sebastian Ertner <sebastian.ertner@netresearch.de>
  13. * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  14. * @link https://www.temando.com/
  15. *
  16. * @api
  17. */
  18. class Notice extends Template
  19. {
  20. /**
  21. * Update the page title depending on where user is coming from,
  22. *
  23. * @return void
  24. */
  25. protected function _construct()
  26. {
  27. try {
  28. $layout = $this->getLayout();
  29. } catch (LocalizedException $exception) {
  30. $this->_logger->error($exception->getLogMessage(), ['exception' => $exception]);
  31. parent::_construct();
  32. return;
  33. }
  34. /** @var $menuBlock \Magento\Backend\Block\Menu */
  35. $menuBlock = $layout->getBlock('menu');
  36. if ($menuBlock) {
  37. $itemId = 'Temando_Shipping::shipping';
  38. $menuBlock->setData('active', $itemId);
  39. $menuItems = $menuBlock->getMenuModel()->getParentItems($itemId);
  40. $menuItems[]= $menuBlock->getMenuModel()->get($itemId);
  41. foreach ($menuItems as $item) {
  42. /** @var $item \Magento\Backend\Model\Menu\Item */
  43. $this->pageConfig->getTitle()->prepend($item->getTitle());
  44. }
  45. }
  46. $subject = $this->getRequest()->getParam('subject');
  47. switch ($subject) {
  48. // merchant account configuration
  49. case 'carrier':
  50. $this->pageConfig->getTitle()->prepend(__('Shipping Partners'));
  51. $this->assign('subject', __('carriers'));
  52. break;
  53. case 'dispatch':
  54. $this->pageConfig->getTitle()->prepend(__('Dispatches'));
  55. $this->assign('subject', __('dispatches'));
  56. break;
  57. case 'location':
  58. $this->pageConfig->getTitle()->prepend(__('Locations'));
  59. $this->assign('subject', __('shipping locations'));
  60. break;
  61. case 'packaging':
  62. $this->pageConfig->getTitle()->prepend(__('Packaging'));
  63. $this->assign('subject', __('packaging types'));
  64. break;
  65. // shipment creation
  66. case 'shipment':
  67. $this->pageConfig->getTitle()->prepend(__('Returns'));
  68. $this->assign('subject', __('RMA shipments'));
  69. break;
  70. case 'batch':
  71. $this->pageConfig->getTitle()->prepend(__('Batches'));
  72. $this->assign('subject', __('batches'));
  73. break;
  74. // settings configuration
  75. case 'advanced':
  76. $this->pageConfig->getTitle()->prepend(__('Advanced Settings'));
  77. $this->assign('subject', __('advanced settings'));
  78. break;
  79. case 'checkout':
  80. $this->pageConfig->getTitle()->prepend(__('Checkout View Settings'));
  81. $this->assign('subject', __('checkout options'));
  82. break;
  83. default:
  84. $this->pageConfig->getTitle()->prepend(__('Magento Shipping'));
  85. $this->assign('subject', __('Magento Shipping'));
  86. }
  87. parent::_construct();
  88. }
  89. /**
  90. * Get the current context, i.e. where the user was forwarded from.
  91. *
  92. * @return string
  93. */
  94. public function getSubject()
  95. {
  96. return $this->_viewVars['subject'];
  97. }
  98. /**
  99. * Obtain module configuration section URL.
  100. *
  101. * @return string
  102. */
  103. public function getConfigUrl()
  104. {
  105. return $this->getUrl('adminhtml/system_config/edit', [
  106. 'section' => 'carriers',
  107. '_fragment' => 'carriers_temando-link',
  108. ]);
  109. }
  110. }