Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Details.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class Details
13 {
17  private $operationCache = [];
18 
22  private $bulkStatus;
23 
27  private $bulkUuid;
28 
34  private $statusMap = [
35  OperationInterface::STATUS_TYPE_COMPLETE => 'operations_successful',
40  ];
41 
48  public function __construct(
49  BulkStatusInterface $bulkStatus,
50  $bulkUuid = null
51  ) {
52  $this->bulkStatus = $bulkStatus;
53  $this->bulkUuid = $bulkUuid;
54  }
55 
62  public function getDetails($bulkUuid)
63  {
64  $details = [
65  'operations_total' => 0,
66  'operations_successful' => 0,
67  'operations_failed' => 0,
68  'failed_retriable' => 0,
69  'failed_not_retriable' => 0,
70  'rejected' => 0,
71  ];
72 
73  if (array_key_exists($bulkUuid, $this->operationCache)) {
74  return $this->operationCache[$bulkUuid];
75  }
76 
77  foreach ($this->statusMap as $statusCode => $readableKey) {
78  $details[$readableKey] = $this->bulkStatus->getOperationsCountByBulkIdAndStatus(
79  $bulkUuid,
80  $statusCode
81  );
82  }
83 
84  $details['operations_total'] = array_sum($details);
85  $details['operations_failed'] = $details['failed_retriable'] + $details['failed_not_retriable'];
86  $this->operationCache[$bulkUuid] = $details;
87 
88  return $details;
89  }
90 
94  public function getOperationsTotal()
95  {
96  $this->getDetails($this->bulkUuid);
97 
98  return $this->operationCache[$this->bulkUuid]['operations_total'];
99  }
100 
104  public function getOpen()
105  {
106  $this->getDetails($this->bulkUuid);
107  $statusKey = $this->statusMap[OperationInterface::STATUS_TYPE_OPEN];
108 
109  return $this->operationCache[$this->bulkUuid][$statusKey];
110  }
111 
115  public function getOperationsSuccessful()
116  {
117  $this->getDetails($this->bulkUuid);
118  $statusKey = $this->statusMap[OperationInterface::STATUS_TYPE_COMPLETE];
119 
120  return $this->operationCache[$this->bulkUuid][$statusKey];
121  }
122 
126  public function getTotalFailed()
127  {
128  $this->getDetails($this->bulkUuid);
129 
130  return $this->operationCache[$this->bulkUuid]['operations_failed'];
131  }
132 
136  public function getFailedNotRetriable()
137  {
138  $statusKey = $this->statusMap[OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED];
139 
140  return $this->operationCache[$this->bulkUuid][$statusKey];
141  }
142 
146  public function getFailedRetriable()
147  {
148  $this->getDetails($this->bulkUuid);
149  $statusKey = $this->statusMap[OperationInterface::STATUS_TYPE_RETRIABLY_FAILED];
150 
151  return $this->operationCache[$this->bulkUuid][$statusKey];
152  }
153 
157  public function getRejected()
158  {
159  $this->getDetails($this->bulkUuid);
160  $statusKey = $this->statusMap[OperationInterface::STATUS_TYPE_REJECTED];
161 
162  return $this->operationCache[$this->bulkUuid][$statusKey];
163  }
164 }
__construct(BulkStatusInterface $bulkStatus, $bulkUuid=null)
Definition: Details.php:48
$details
Definition: vault.phtml:10