1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\Integration\Renderer; |
4
|
|
|
|
5
|
|
|
use Magento\Integration\Model\Integration; |
6
|
|
|
use Magento\Integration\Model\Oauth\Consumer; |
7
|
|
|
use Magento\Integration\Model\Oauth\Token; |
8
|
|
|
use Symfony\Component\Console\Helper\Table; |
9
|
|
|
use Symfony\Component\Console\Helper\TableSeparator; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class TableRenderer |
14
|
|
|
* @package N98\Magento\Command\Integration\Renderer |
15
|
|
|
*/ |
16
|
|
|
class TableRenderer |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var OutputInterface |
20
|
|
|
*/ |
21
|
|
|
private $output; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var Integration |
25
|
|
|
*/ |
26
|
|
|
private $integrationModel; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var Consumer |
30
|
|
|
*/ |
31
|
|
|
private $consumerModel; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var Token |
35
|
|
|
*/ |
36
|
|
|
private $tokenModel; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* TableRenderer constructor. |
40
|
|
|
* @param OutputInterface $output |
41
|
|
|
* @param Integration $integrationModel |
42
|
|
|
* @param Consumer $consumerModel |
43
|
|
|
* @param Token $tokenModel |
44
|
|
|
*/ |
45
|
|
|
public function __construct( |
46
|
|
|
OutputInterface $output, |
47
|
|
|
Integration $integrationModel, |
48
|
|
|
Consumer $consumerModel, |
49
|
|
|
Token $tokenModel |
50
|
|
|
) { |
51
|
|
|
$this->output = $output; |
52
|
|
|
$this->integrationModel = $integrationModel; |
53
|
|
|
$this->consumerModel = $consumerModel; |
54
|
|
|
$this->tokenModel = $tokenModel; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function render() |
58
|
|
|
{ |
59
|
|
|
$table = new Table($this->output); |
60
|
|
|
$table->setRows([ |
61
|
|
|
['Integration ID', $this->integrationModel->getId()], |
62
|
|
|
['Name', $this->integrationModel->getName()], |
63
|
|
|
['Email', $this->integrationModel->getEmail()], |
64
|
|
|
['Endpoint', $this->integrationModel->getEndpoint()], |
65
|
|
|
['Status', $this->integrationModel->getStatus() == Integration::STATUS_ACTIVE ? 'Active' : 'Inactive'], |
66
|
|
|
new TableSeparator(), |
67
|
|
|
['Consumer Key', $this->consumerModel->getKey()], |
68
|
|
|
['Consumer Secret', $this->consumerModel->getSecret()], |
69
|
|
|
new TableSeparator(), |
70
|
|
|
['Access Token', $this->tokenModel->getToken()], |
71
|
|
|
['Access Token Secret', $this->tokenModel->getSecret()], |
72
|
|
|
]); |
73
|
|
|
$table->render(); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|