|
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\Business\Exporter; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\BatchResultTransfer; |
|
|
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\LocaleTransfer; |
|
|
|
|
|
|
12
|
|
|
use Spryker\Shared\Kernel\Store; |
|
13
|
|
|
use SprykerEco\Zed\Econda\Business\Exporter\Exception\BatchResultException; |
|
14
|
|
|
use SprykerEco\Zed\Econda\Dependency\Facade\EcondaToLocaleFacadeInterface; |
|
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
16
|
|
|
|
|
17
|
|
|
class Runner implements RunnerInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \SprykerEco\Zed\Econda\Business\Exporter\ExporterInterface |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $exporter; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \SprykerEco\Zed\Econda\Dependency\Facade\EcondaToLocaleFacadeInterface |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $localeFacade; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param \SprykerEco\Zed\Econda\Dependency\Facade\EcondaToLocaleFacadeInterface $localeFacade |
|
31
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Exporter\ExporterInterface $exporter |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct( |
|
34
|
|
|
EcondaToLocaleFacadeInterface $localeFacade, |
|
35
|
|
|
ExporterInterface $exporter |
|
36
|
|
|
) { |
|
37
|
|
|
$this->localeFacade = $localeFacade; |
|
38
|
|
|
$this->exporter = $exporter; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
|
43
|
|
|
* |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
|
|
public function runExport(OutputInterface $output): array |
|
47
|
|
|
{ |
|
48
|
|
|
$storeCollection = Store::getInstance()->getAllowedStores(); |
|
49
|
|
|
|
|
50
|
|
|
$results = []; |
|
51
|
|
|
|
|
52
|
|
|
foreach ($storeCollection as $storeName) { |
|
53
|
|
|
$output->writeln(''); |
|
54
|
|
|
$output->writeln('<fg=yellow>----------------------------------------</fg=yellow>'); |
|
55
|
|
|
$output->writeln(sprintf( |
|
56
|
|
|
'<fg=yellow>Exporting Store:</fg=yellow> <fg=white>%s</fg=white>', |
|
57
|
|
|
$storeName |
|
58
|
|
|
)); |
|
59
|
|
|
$output->writeln(''); |
|
60
|
|
|
|
|
61
|
|
|
$localeCollection = Store::getInstance()->getLocalesPerStore($storeName); |
|
62
|
|
|
foreach ($localeCollection as $localeCode) { |
|
63
|
|
|
$localeTransfer = $this->localeFacade->getLocale($localeCode); |
|
64
|
|
|
$results[$storeName . '@' . $localeCode] = $this->exportStoreByLocale($localeTransfer, $output); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return $results; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @param \Generated\Shared\Transfer\LocaleTransfer $locale |
|
73
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
|
74
|
|
|
* |
|
75
|
|
|
* @return array |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function exportStoreByLocale(LocaleTransfer $locale, OutputInterface $output): array |
|
78
|
|
|
{ |
|
79
|
|
|
$results = []; |
|
80
|
|
|
$types = $this->getEnabledExports(); |
|
81
|
|
|
|
|
82
|
|
|
$output->writeln(''); |
|
83
|
|
|
$output->writeln(sprintf('<fg=yellow>Locale:</fg=yellow> <fg=white>%s</fg=white>', $locale->getLocaleName())); |
|
84
|
|
|
$output->writeln('<fg=yellow>-------------</fg=yellow>'); |
|
85
|
|
|
|
|
86
|
|
|
foreach ($types as $type) { |
|
87
|
|
|
$result = $this->exporter->exportByType($type, $locale, $output); |
|
88
|
|
|
|
|
89
|
|
|
$this->handleResult($result); |
|
90
|
|
|
|
|
91
|
|
|
if ($result !== null) { |
|
92
|
|
|
if ($this->nothingWasProcessed($result)) { |
|
93
|
|
|
continue; |
|
94
|
|
|
} |
|
95
|
|
|
$results[$type] = $result; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
return $results; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param \Generated\Shared\Transfer\BatchResultTransfer $result |
|
104
|
|
|
* |
|
105
|
|
|
* @return bool |
|
106
|
|
|
*/ |
|
107
|
|
|
protected function nothingWasProcessed(BatchResultTransfer $result): bool |
|
108
|
|
|
{ |
|
109
|
|
|
return $result->getProcessedCount() === 0; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @param \Generated\Shared\Transfer\BatchResultTransfer $result |
|
114
|
|
|
* |
|
115
|
|
|
* @throws \SprykerEco\Zed\Econda\Business\Exporter\Exception\BatchResultException |
|
116
|
|
|
* |
|
117
|
|
|
* @return void |
|
118
|
|
|
*/ |
|
119
|
|
|
protected function handleResult(BatchResultTransfer $result): void |
|
120
|
|
|
{ |
|
121
|
|
|
if ($result->getFailedCount()) { |
|
122
|
|
|
throw new BatchResultException( |
|
123
|
|
|
sprintf( |
|
124
|
|
|
'Processed %d from %d for locale %s, where %d were deleted and %d failed.', |
|
125
|
|
|
$result->getProcessedCount(), |
|
126
|
|
|
$result->getTotalCount(), |
|
127
|
|
|
$result->getProcessedLocale()->getLocaleName(), |
|
128
|
|
|
$result->getDeletedCount(), |
|
129
|
|
|
$result->getFailedCount() |
|
130
|
|
|
) |
|
131
|
|
|
); |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @return array |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getEnabledExports(): array |
|
139
|
|
|
{ |
|
140
|
|
|
return array_keys($this->exporter->getCollectorPlugins()); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
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