1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Odiseo\SyliusMailchimpPlugin\Command; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
8
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
9
|
|
|
use Symfony\Component\Console\Input\InputOption; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
12
|
|
|
|
13
|
|
|
final class SyncAllCommand extends BaseSyncCommand |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritdoc} |
17
|
|
|
*/ |
18
|
|
|
protected function configure(): void |
19
|
|
|
{ |
20
|
|
|
$this |
21
|
|
|
->setName('odiseo:mailchimp:sync-all') |
22
|
|
|
->setDescription('Synchronize all data to Mailchimp.') |
23
|
|
|
->addOption('create-only', 'c', InputOption::VALUE_NONE, 'With this option the existing content will be not updated.') |
24
|
|
|
->addOption('purge', 'p', InputOption::VALUE_NONE, 'Reset all the content and reload from scratch.') |
25
|
|
|
; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
32
|
|
|
{ |
33
|
|
|
$withPurge = $input->getOption('purge'); |
34
|
|
|
$createOnly = $input->getOption('create-only'); |
35
|
|
|
|
36
|
|
|
$this->io = new SymfonyStyle($input, $output); |
37
|
|
|
|
38
|
|
|
$this->io->title('Synchronizing all data to Mailchimp'); |
39
|
|
|
|
40
|
|
|
$application = $this->getApplication(); |
41
|
|
|
|
42
|
|
|
if ($application) { |
43
|
|
|
$syncStoresCommand = $application->find('odiseo:mailchimp:sync-stores'); |
44
|
|
|
$syncCustomersCommand = $application->find('odiseo:mailchimp:sync-customers'); |
45
|
|
|
$syncProductsCommand = $application->find('odiseo:mailchimp:sync-products'); |
46
|
|
|
$syncCartsCommand = $application->find('odiseo:mailchimp:sync-carts'); |
47
|
|
|
$syncOrdersCommand = $application->find('odiseo:mailchimp:sync-orders'); |
48
|
|
|
|
49
|
|
|
$syncStoresCommand->run(new ArrayInput([ |
50
|
|
|
'--isSyncing' => true, |
51
|
|
|
'--purge' => $withPurge, |
52
|
|
|
]), $output); |
53
|
|
|
|
54
|
|
|
$syncCustomersCommand->run(new ArrayInput([ |
55
|
|
|
'--create-only' => $createOnly, |
56
|
|
|
]), $output); |
57
|
|
|
$syncProductsCommand->run(new ArrayInput([ |
58
|
|
|
'--create-only' => $createOnly, |
59
|
|
|
]), $output); |
60
|
|
|
$syncCartsCommand->run(new ArrayInput([ |
61
|
|
|
'--create-only' => $createOnly, |
62
|
|
|
]), $output); |
63
|
|
|
$syncOrdersCommand->run(new ArrayInput([ |
64
|
|
|
'--create-only' => $createOnly, |
65
|
|
|
]), $output); |
66
|
|
|
|
67
|
|
|
$syncStoresCommand->run(new ArrayInput([ |
68
|
|
|
'--isSyncing' => false, |
69
|
|
|
]), $output); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return 0; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|