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; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\BatchResultTransfer; |
11
|
|
|
use Generated\Shared\Transfer\LocaleTransfer; |
12
|
|
|
use Spryker\Zed\Kernel\Business\AbstractFacade; |
13
|
|
|
use SprykerEco\Zed\Econda\Business\Collector\AbstractDatabaseCollector; |
14
|
|
|
use SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @method \SprykerEco\Zed\Econda\Business\EcondaBusinessFactory getFactory() |
19
|
|
|
*/ |
20
|
|
|
class EcondaFacade extends AbstractFacade implements EcondaFacadeInterface |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @api |
25
|
|
|
* |
26
|
|
|
* @param string $type |
27
|
|
|
* @param string $locale |
28
|
|
|
* |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
|
|
public function getFileContent($type, $locale) |
32
|
|
|
{ |
33
|
|
|
return $this->getFactory()->getEcondaCsvFileContent($type, $locale); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
38
|
|
|
* |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
|
|
public function exportFile(OutputInterface $output) |
42
|
|
|
{ |
43
|
|
|
return $this->getFactory()->createRunner()->runExport($output); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer |
48
|
|
|
* @param \Generated\Shared\Transfer\BatchResultTransfer $result |
49
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface $dataWriter |
50
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function exportCategories( |
55
|
|
|
LocaleTransfer $localeTransfer, |
56
|
|
|
BatchResultTransfer $result, |
57
|
|
|
WriterInterface $dataWriter, |
58
|
|
|
OutputInterface $output |
59
|
|
|
) { |
60
|
|
|
$collector = $this->getFactory()->createFileCategoryCollector(); |
61
|
|
|
$this->export( |
62
|
|
|
$collector, |
63
|
|
|
$localeTransfer, |
64
|
|
|
$result, |
65
|
|
|
$dataWriter, |
66
|
|
|
$output |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer |
72
|
|
|
* @param \Generated\Shared\Transfer\BatchResultTransfer $result |
73
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface $dataWriter |
74
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
75
|
|
|
* |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
|
public function exportProducts( |
79
|
|
|
LocaleTransfer $localeTransfer, |
80
|
|
|
BatchResultTransfer $result, |
81
|
|
|
WriterInterface $dataWriter, |
82
|
|
|
OutputInterface $output |
83
|
|
|
) { |
84
|
|
|
$collector = $this->getFactory()->createFileProductCollector(); |
85
|
|
|
$this->export( |
86
|
|
|
$collector, |
87
|
|
|
$localeTransfer, |
88
|
|
|
$result, |
89
|
|
|
$dataWriter, |
90
|
|
|
$output |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Collector\AbstractDatabaseCollector $collector |
96
|
|
|
* @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer |
97
|
|
|
* @param \Generated\Shared\Transfer\BatchResultTransfer $result |
98
|
|
|
* @param \SprykerEco\Zed\Econda\Business\Exporter\Writer\WriterInterface $dataWriter |
99
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
100
|
|
|
* |
101
|
|
|
* @return void |
102
|
|
|
*/ |
103
|
|
|
private function export( |
104
|
|
|
AbstractDatabaseCollector $collector, |
105
|
|
|
LocaleTransfer $localeTransfer, |
106
|
|
|
BatchResultTransfer $result, |
107
|
|
|
WriterInterface $dataWriter, |
108
|
|
|
OutputInterface $output |
109
|
|
|
) { |
110
|
|
|
$this->getFactory() |
111
|
|
|
->createCollectorManager() |
112
|
|
|
->runCollector( |
113
|
|
|
$collector, |
114
|
|
|
$localeTransfer, |
115
|
|
|
$result, |
116
|
|
|
$dataWriter, |
117
|
|
|
$output |
118
|
|
|
); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
} |
122
|
|
|
|