1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Econda\Communication\Console; |
9
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Communication\Console\Console; |
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @method \SprykerEco\Zed\Econda\Business\EcondaFacade getFacade() |
17
|
|
|
*/ |
18
|
|
|
class EcondaFileExportConsole extends Console |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
const COMMAND_NAME = 'econda:file:export'; |
22
|
|
|
const COMMAND_DESCRIPTION = 'Export data to files'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @return \Symfony\Component\Console\Helper\HelperSet |
26
|
|
|
*/ |
27
|
|
|
public function getHelperSet() |
28
|
|
|
{ |
29
|
|
|
return new HelperSet(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
protected function configure() |
36
|
|
|
{ |
37
|
|
|
$this->setName(self::COMMAND_NAME); |
38
|
|
|
$this->setDescription(self::COMMAND_DESCRIPTION); |
39
|
|
|
|
40
|
|
|
parent::configure(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
45
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
46
|
|
|
* |
47
|
|
|
* @return int|null|void |
48
|
|
|
*/ |
49
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
50
|
|
|
{ |
51
|
|
|
$exportResults = $this->getFacade()->exportFile($output); |
52
|
|
|
$message = $this->buildNestedSummary($exportResults); |
53
|
|
|
$message = '<info>' . $message . '</info>'; |
54
|
|
|
|
55
|
|
|
$output->write($message); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Model\BatchResultInterface[] $resultData |
60
|
|
|
* |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
protected function buildSummary(array $resultData) |
64
|
|
|
{ |
65
|
|
|
if (empty($resultData)) { |
66
|
|
|
return PHP_EOL . '<fg=yellow>Nothing exported.</fg=yellow>' . PHP_EOL; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$summary = PHP_EOL; |
70
|
|
|
|
71
|
|
|
ksort($resultData); |
72
|
|
|
foreach ($resultData as $type => $result) { |
73
|
|
|
$summary .= sprintf( |
74
|
|
|
' <fg=green>%s</fg=green><fg=yellow> </fg=yellow><fg=yellow></fg=yellow>' . PHP_EOL . |
75
|
|
|
' <fg=white>Total: %d</fg=white>' . PHP_EOL . |
76
|
|
|
' <fg=white>Processed: %d</fg=white>' . PHP_EOL . |
77
|
|
|
' <fg=white>Succeeded: %s</fg=white>' . PHP_EOL . |
78
|
|
|
' <fg=white>Deleted: %s</fg=white>' . PHP_EOL . |
79
|
|
|
' <fg=white>Failed: %s </fg=white>' . PHP_EOL, |
80
|
|
|
mb_strtoupper($type), |
81
|
|
|
$result->getTotalCount(), |
82
|
|
|
$result->getProcessedCount(), |
83
|
|
|
$result->getSuccessCount() > 0 ? '<fg=green>' . $result->getSuccessCount() . '</fg=green>' : $result->getSuccessCount(), |
84
|
|
|
$result->getDeletedCount() > 0 ? '<fg=yellow>' . $result->getDeletedCount() . '</fg=yellow>' : $result->getDeletedCount(), |
85
|
|
|
$result->isFailed() ? '<fg=red>' . $result->getFailedCount() . '</fg=red>' : $result->getFailedCount() |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
$summary .= PHP_EOL; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $summary . PHP_EOL; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Model\BatchResultInterface[] $results |
96
|
|
|
* |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
protected function buildNestedSummary(array $results) |
100
|
|
|
{ |
101
|
|
|
$summary = ''; |
102
|
|
|
foreach ($results as $localeName => $summaryData) { |
103
|
|
|
$summary .= PHP_EOL; |
104
|
|
|
$summary .= '<fg=yellow>----------------------------------------</fg=yellow>'; |
105
|
|
|
$summary .= PHP_EOL; |
106
|
|
|
$summary .= sprintf('<fg=yellow>Summary:</fg=yellow> <fg=white>%s</fg=white>', $localeName); |
107
|
|
|
$summary .= PHP_EOL; |
108
|
|
|
$summary .= $this->buildSummary($summaryData); |
|
|
|
|
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$summary .= PHP_EOL . 'All done.' . PHP_EOL; |
112
|
|
|
|
113
|
|
|
return $summary; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
} |
117
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths