Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Manager.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\Integration\Api\AuthorizationServiceInterface as IntegrationAuthorizationInterface;
11 
16 class Manager
17 {
24 
29 
35  protected $integrationConfig;
36 
44  public function __construct(
45  IntegrationAuthorizationInterface $integrationAuthorizationService,
46  \Magento\Integration\Api\IntegrationServiceInterface $integrationService,
48  ) {
49  $this->integrationAuthorizationService = $integrationAuthorizationService;
50  $this->_integrationService = $integrationService;
51  $this->integrationConfig = $integrationConfig;
52  }
53 
64  public function afterProcessIntegrationConfig(
66  $integrationNames
67  ) {
68  if (empty($integrationNames)) {
69  return [];
70  }
72  $integrations = $this->integrationConfig->getIntegrations();
73  foreach ($integrationNames as $name) {
74  if (isset($integrations[$name])) {
75  $integration = $this->_integrationService->findByName($name);
76  if ($integration->getId()) {
77  $this->integrationAuthorizationService->grantPermissions(
78  $integration->getId(),
79  $integrations[$name]['resource']
80  );
81  }
82  }
83  }
84  return $integrationNames;
85  }
86 
98  $integrations
99  ) {
100  if (empty($integrations)) {
101  return [];
102  }
103 
104  foreach (array_keys($integrations) as $name) {
105  $integration = $this->_integrationService->findByName($name);
106  if ($integration->getId()) {
107  $this->integrationAuthorizationService->grantPermissions(
108  $integration->getId(),
109  $integrations[$name]['resource']
110  );
111  }
112  }
113  return $integrations;
114  }
115 }
afterProcessConfigBasedIntegrations(ConfigBasedIntegrationManager $subject, $integrations)
Definition: Manager.php:96
__construct(IntegrationAuthorizationInterface $integrationAuthorizationService, \Magento\Integration\Api\IntegrationServiceInterface $integrationService, IntegrationConfig $integrationConfig)
Definition: Manager.php:44
if(!isset($_GET['name'])) $name
Definition: log.php:14