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