View.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Sales\Controller\Adminhtml\Shipment\AbstractShipment;
  8. use Magento\Backend\App\Action\Context;
  9. use Magento\Backend\Model\View\Result\ForwardFactory;
  10. abstract class View extends \Magento\Backend\App\Action
  11. {
  12. /**
  13. * Authorization level of a basic admin session
  14. *
  15. * @see _isAllowed()
  16. */
  17. const ADMIN_RESOURCE = 'Magento_Sales::shipment';
  18. /**
  19. * @var ForwardFactory
  20. */
  21. protected $resultForwardFactory;
  22. /**
  23. * @param Context $context
  24. * @param ForwardFactory $resultForwardFactory
  25. */
  26. public function __construct(
  27. Context $context,
  28. ForwardFactory $resultForwardFactory
  29. ) {
  30. parent::__construct($context);
  31. $this->resultForwardFactory = $resultForwardFactory;
  32. }
  33. /**
  34. * Shipment information page
  35. *
  36. * @return \Magento\Backend\Model\View\Result\Forward
  37. */
  38. public function execute()
  39. {
  40. /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */
  41. $resultForward = $this->resultForwardFactory->create();
  42. if ($this->getRequest()->getParam('shipment_id')) {
  43. $resultForward->setController('order_shipment')
  44. ->setModule('admin')
  45. ->setParams(['come_from' => 'shipment'])
  46. ->forward('view');
  47. return $resultForward;
  48. } else {
  49. return $resultForward->forward('noroute');
  50. }
  51. }
  52. }