OrderViewAuthorization.php 894 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Sales\Controller\Guest;
  8. use Magento\Sales\Controller\AbstractController\OrderViewAuthorizationInterface;
  9. class OrderViewAuthorization implements OrderViewAuthorizationInterface
  10. {
  11. /**
  12. * @var \Magento\Framework\Registry
  13. */
  14. protected $registry;
  15. /**
  16. * @param \Magento\Framework\Registry $registry
  17. */
  18. public function __construct(\Magento\Framework\Registry $registry)
  19. {
  20. $this->registry = $registry;
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function canView(\Magento\Sales\Model\Order $order)
  26. {
  27. $currentOrder = $this->registry->registry('current_order');
  28. if ($order->getId() && $order->getId() === $currentOrder->getId()) {
  29. return true;
  30. }
  31. return false;
  32. }
  33. }