|
9 | 9 | use Magento\Framework\App\Filesystem\DirectoryList; |
10 | 10 |
|
11 | 11 | /** |
| 12 | + * Class Export for exporting grid data as CSV file or MS Excel 2003 XML Document file |
| 13 | + * |
12 | 14 | * @api |
13 | 15 | * @deprecated 100.2.0 in favour of UI component implementation |
14 | 16 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
@@ -69,6 +71,8 @@ public function __construct( |
69 | 71 | } |
70 | 72 |
|
71 | 73 | /** |
| 74 | + * Internal constructor, that is called from real constructor |
| 75 | + * |
72 | 76 | * @return void |
73 | 77 | * @throws \Magento\Framework\Exception\LocalizedException |
74 | 78 | */ |
@@ -242,6 +246,7 @@ protected function _getExportTotals() |
242 | 246 |
|
243 | 247 | /** |
244 | 248 | * Iterate collection and call callback method per item |
| 249 | + * |
245 | 250 | * For callback method first argument always is item object |
246 | 251 | * |
247 | 252 | * @param string $callback |
@@ -273,7 +278,12 @@ public function _exportIterateCollection($callback, array $args) |
273 | 278 |
|
274 | 279 | $collection = $this->_getRowCollection($originalCollection); |
275 | 280 | foreach ($collection as $item) { |
276 | | - call_user_func_array([$this, $callback], array_merge([$item], $args)); |
| 281 | + //phpcs:ignore Magento2.Functions.DiscouragedFunction |
| 282 | + call_user_func_array( |
| 283 | + [$this, $callback], |
| 284 | + // phpcs:ignore Magento2.Performance.ForeachArrayMerge |
| 285 | + array_merge([$item], $args) |
| 286 | + ); |
277 | 287 | } |
278 | 288 | } |
279 | 289 | } |
@@ -307,7 +317,7 @@ protected function _exportCsvItem( |
307 | 317 | */ |
308 | 318 | public function getCsvFile() |
309 | 319 | { |
310 | | - $name = md5(microtime()); |
| 320 | + $name = hash('sha256', microtime()); |
311 | 321 | $file = $this->_path . '/' . $name . '.csv'; |
312 | 322 |
|
313 | 323 | $this->_directory->create($this->_path); |
@@ -432,11 +442,11 @@ public function getRowRecord(\Magento\Framework\DataObject $data) |
432 | 442 | */ |
433 | 443 | public function getExcelFile($sheetName = '') |
434 | 444 | { |
435 | | - $collection = $this->_getRowCollection(); |
| 445 | + $collection = $this->_getPreparedCollection(); |
436 | 446 |
|
437 | 447 | $convert = new \Magento\Framework\Convert\Excel($collection->getIterator(), [$this, 'getRowRecord']); |
438 | 448 |
|
439 | | - $name = md5(microtime()); |
| 449 | + $name = hash('sha256', microtime()); |
440 | 450 | $file = $this->_path . '/' . $name . '.xml'; |
441 | 451 |
|
442 | 452 | $this->_directory->create($this->_path); |
@@ -551,6 +561,8 @@ public function _getPreparedCollection() |
551 | 561 | } |
552 | 562 |
|
553 | 563 | /** |
| 564 | + * Get export page size |
| 565 | + * |
554 | 566 | * @return int |
555 | 567 | */ |
556 | 568 | public function getExportPageSize() |
|
0 commit comments