-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathSynchronizeMergeFieldsCommand.php
More file actions
56 lines (45 loc) · 1.52 KB
/
SynchronizeMergeFieldsCommand.php
File metadata and controls
56 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Welp\MailchimpBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Welp\MailchimpBundle\Provider\ListProviderInterface;
use Welp\MailchimpBundle\Subscriber\ListSynchronizer;
class SynchronizeMergeFieldsCommand extends Command
{
/**
* List Synchronizer.
*
* @var ListSynchronizer
*/
private ListSynchronizer $listSynchronizer;
/**
* The configured list provider.
*
* @var ListProviderInterface
*/
private ListProviderInterface $listProvider;
public function __construct(ListSynchronizer $listSynchronizer, ListProviderInterface $listProvider)
{
$this->listSynchronizer = $listSynchronizer;
$this->listProvider = $listProvider;
parent::__construct();
}
protected function configure(): void
{
$this
->setDescription('Synchronizing merge fields in MailChimp')
->setName('welp:mailchimp:synchronize-merge-fields')
// @TODO add params : listId
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(sprintf('<info>%s</info>', $this->getDescription()));
$lists = $this->listProvider->getLists();
foreach ($lists as $list) {
$this->listSynchronizer->synchronizeMergeFields($list->getListId(), $list->getMergeFields());
}
return Command::SUCCESS;
}
}