Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaseInfo.php
Go to the documentation of this file.
1 <?php
7 
12 
19 class CaseInfo extends Template
20 {
24  private $caseEntity = false;
25 
29  private $caseManagement;
30 
36  public function __construct(
37  Context $context,
38  CaseManagement $caseManagement,
39  array $data = []
40  ) {
41  $this->caseManagement = $caseManagement;
42 
43  parent::__construct($context, $data);
44  }
45 
51  private function getCaseEntity()
52  {
53  if ($this->caseEntity === false) {
54  $this->caseEntity = $this->caseManagement->getByOrderId(
55  $this->getOrderId()
56  );
57  }
58 
59  return $this->caseEntity;
60  }
61 
69  private function getCaseProperty($defaultValue, callable $callback)
70  {
71  return $this->isEmptyCase() ? $defaultValue : call_user_func($callback);
72  }
73 
80  public function isEmptyCase()
81  {
82  return $this->getCaseEntity() === null;
83  }
84 
91  public function getCaseGuaranteeDisposition()
92  {
93  return $this->getCaseProperty('', function () {
94  $guaranteeStatusMap = [
99  CaseInterface::GUARANTEE_IN_REVIEW => __('In Review'),
100  CaseInterface::GUARANTEE_UNREQUESTED => __('Unrequested')
101  ];
102 
103  $status = isset($guaranteeStatusMap[$this->getCaseEntity()->getGuaranteeDisposition()]) ?
104  $guaranteeStatusMap[$this->getCaseEntity()->getGuaranteeDisposition()] :
105  '';
106 
107  return $status;
108  });
109  }
110 
116  private function getOrderId()
117  {
118  return (int) $this->getRequest()->getParam('order_id');
119  }
120 }
__()
Definition: __.php:13
__construct(Context $context, CaseManagement $caseManagement, array $data=[])
Definition: CaseInfo.php:36
$status
Definition: order_status.php:8