Popup.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Shipping\Controller\Tracking;
  8. use Magento\Framework\Exception\NotFoundException;
  9. class Popup extends \Magento\Framework\App\Action\Action
  10. {
  11. /**
  12. * Core registry
  13. *
  14. * @var \Magento\Framework\Registry
  15. */
  16. protected $_coreRegistry;
  17. /**
  18. * @var \Magento\Shipping\Model\InfoFactory
  19. */
  20. protected $_shippingInfoFactory;
  21. /**
  22. * @var \Magento\Sales\Model\OrderFactory
  23. */
  24. protected $_orderFactory;
  25. /**
  26. * @param \Magento\Framework\App\Action\Context $context
  27. * @param \Magento\Framework\Registry $coreRegistry
  28. * @param \Magento\Shipping\Model\InfoFactory $shippingInfoFactory
  29. * @param \Magento\Sales\Model\OrderFactory $orderFactory
  30. */
  31. public function __construct(
  32. \Magento\Framework\App\Action\Context $context,
  33. \Magento\Framework\Registry $coreRegistry,
  34. \Magento\Shipping\Model\InfoFactory $shippingInfoFactory,
  35. \Magento\Sales\Model\OrderFactory $orderFactory
  36. ) {
  37. $this->_coreRegistry = $coreRegistry;
  38. $this->_shippingInfoFactory = $shippingInfoFactory;
  39. $this->_orderFactory = $orderFactory;
  40. parent::__construct($context);
  41. }
  42. /**
  43. * Popup action
  44. * Shows tracking info if it's present, otherwise redirects to 404
  45. *
  46. * @return void
  47. * @throws NotFoundException
  48. */
  49. public function execute()
  50. {
  51. $shippingInfoModel = $this->_shippingInfoFactory->create()->loadByHash($this->getRequest()->getParam('hash'));
  52. $this->_coreRegistry->register('current_shipping_info', $shippingInfoModel);
  53. if (count($shippingInfoModel->getTrackingInfo()) == 0) {
  54. throw new NotFoundException(__('Page not found.'));
  55. }
  56. $this->_view->loadLayout();
  57. $this->_view->getPage()->getConfig()->getTitle()->set(__('Tracking Information'));
  58. $this->_view->renderLayout();
  59. }
  60. }