Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderViewAuthorization.php
Go to the documentation of this file.
1 <?php
9 
11 {
15  protected $customerSession;
16 
20  protected $orderConfig;
21 
26  public function __construct(
27  \Magento\Customer\Model\Session $customerSession,
28  \Magento\Sales\Model\Order\Config $orderConfig
29  ) {
30  $this->customerSession = $customerSession;
31  $this->orderConfig = $orderConfig;
32  }
33 
37  public function canView(\Magento\Sales\Model\Order $order)
38  {
39  $customerId = $this->customerSession->getCustomerId();
40  $availableStatuses = $this->orderConfig->getVisibleOnFrontStatuses();
41  if ($order->getId()
42  && $order->getCustomerId()
43  && $order->getCustomerId() == $customerId
44  && in_array($order->getStatus(), $availableStatuses, true)
45  ) {
46  return true;
47  }
48  return false;
49  }
50 }
__construct(\Magento\Customer\Model\Session $customerSession, \Magento\Sales\Model\Order\Config $orderConfig)
$order
Definition: order.php:55