Ejemplo n.º 1
0
 /**
  * Process integration resource permissions after the integration is created
  *
  * @param \Magento\Integration\Model\Resource\Setup $subject
  * @param string[] $integrationNames Name of integrations passed as array from the invocation chain
  *
  * @return string[]
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterInitIntegrationProcessing(\Magento\Integration\Model\Resource\Setup $subject, $integrationNames)
 {
     if (empty($integrationNames)) {
         return [];
     }
     /** @var array $integrations */
     $integrations = $this->_integrationConfig->getIntegrations();
     foreach ($integrationNames as $name) {
         if (isset($integrations[$name])) {
             $integration = $this->_integrationService->findByName($name);
             if ($integration->getId()) {
                 $this->integrationAuthorizationService->grantPermissions($integration->getId(), $integrations[$name]['resources']);
             }
         }
     }
     return $integrationNames;
 }
Ejemplo n.º 2
0
 /**
  * Process integration resource permissions after the integration is created
  *
  * @param ConfigBasedIntegrationManager $subject
  * @param string[] $integrationNames Name of integrations passed as array from the invocation chain
  *
  * @return string[]
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterProcessIntegrationConfig(ConfigBasedIntegrationManager $subject, $integrationNames)
 {
     if (empty($integrationNames)) {
         return [];
     }
     /** @var array $integrations */
     $integrations = $this->_integrationConfig->getIntegrations();
     foreach ($integrationNames as $name) {
         if (isset($integrations[$name])) {
             $integration = $this->_integrationService->findByName($name);
             if ($integration->getId()) {
                 $this->integrationAuthorizationService->grantPermissions($integration->getId(), $integrations[$name]['resources']);
             }
         }
     }
     return $integrationNames;
 }
Ejemplo n.º 3
0
 /**
  * Persist API permissions.
  *
  * Permissions are expected to be set to integration object by 'resource' key.
  * If 'all_resources' is set and is evaluated to true, permissions to all resources will be granted.
  *
  * @param IntegrationModel $integration
  * @return void
  */
 protected function _saveApiPermissions(IntegrationModel $integration)
 {
     if ($integration->getId()) {
         if ($integration->getData('all_resources')) {
             $this->integrationAuthorizationService->grantAllPermissions($integration->getId());
         } elseif (is_array($integration->getData('resource'))) {
             $this->integrationAuthorizationService->grantPermissions($integration->getId(), $integration->getData('resource'));
         } else {
             $this->integrationAuthorizationService->grantPermissions($integration->getId(), []);
         }
     }
 }