-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommands.php
70 lines (59 loc) · 1.93 KB
/
Commands.php
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @category Tun2U
* @package Tun2U_KlaviyoAddons
* @author Tun2U Team <[email protected]>
* @copyright Copyright(c) 2022 Tun2U (https://www.tun2u.com)
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License (GPL 3.0)
*/
namespace Tun2U\KlaviyoAddons\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class Commands extends Command
{
/**
* @var \Tun2U\KlaviyoAddons\Service\KlaviyoService
*/
private $klaviyoService;
/**
* Commands constructor.
*
* @param \Tun2U\KlaviyoAddons\Service\KlaviyoService $klaviyoService
*/
public function __construct(
\Tun2U\KlaviyoAddons\Service\KlaviyoService $klaviyoService
) {
$this->klaviyoService = $klaviyoService;
parent::__construct();
}
/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName('tun2u:klaviyoaddons')
->setDescription('Klaviyo addons')
->addOption('action', "action", InputOption::VALUE_REQUIRED, "Specific Action (sync_unsubscribed_users)");
parent::configure();
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$action = null;
try {
$action = $input->getOption('action');
if ($action == 'sync_unsubscribed_users') {
$result = $this->klaviyoService->syncUnsubscribedUsers();
$output->writeln($result);
}
} catch (\InvalidArgumentException $e) {
$output->writeln('<error>Invalid argument.</error>');
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
}
}