Esempio n. 1
0
 /**
  * Process integration resource permissions after the integration is created
  *
  * @param ConfigBasedIntegrationManager $subject
  * @param array $integrations integrations passed as array from the invocation chain
  *
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterProcessIntegrationConfig(ConfigBasedIntegrationManager $subject, $integrations)
 {
     if (empty($integrations)) {
         return [];
     }
     /** @var array $integrationsResource */
     $integrationsResource = $this->_integrationConfig->getIntegrations();
     foreach (array_keys($integrations) as $name) {
         if (isset($integrationsResource[$name])) {
             $integration = $this->_integrationService->findByName($name);
             if ($integration->getId()) {
                 $this->integrationAuthorizationService->grantPermissions($integration->getId(), $integrationsResource[$name]['resource']);
             }
         }
     }
     return $integrations;
 }
Esempio n. 2
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(), []);
         }
     }
 }