Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
IntegrationManager Class Reference

Public Member Functions

 __construct (SystemConfig $config, IntegrationServiceInterface $integrationService, OauthServiceInterface $oauthService)
 
 activateIntegration ()
 
 generateToken ()
 

Detailed Description

Manages the integration user at magento side. User name stored in config. User roles

Definition at line 20 of file IntegrationManager.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( SystemConfig  $config,
IntegrationServiceInterface  $integrationService,
OauthServiceInterface  $oauthService 
)

IntegrationManager constructor

Parameters
SystemConfig$config
IntegrationServiceInterface$integrationService
OauthServiceInterface$oauthService

Definition at line 44 of file IntegrationManager.php.

48  {
49  $this->integrationService = $integrationService;
50  $this->config = $config;
51  $this->oauthService = $oauthService;
52  }

Member Function Documentation

◆ activateIntegration()

activateIntegration ( )

Activate predefined integration user

Returns
bool
Exceptions
NoSuchEntityException

Definition at line 60 of file IntegrationManager.php.

61  {
62  $integration = $this->integrationService->findByName(
63  $this->config->getConfigDataValue('analytics/integration_name')
64  );
65  if (!$integration->getId()) {
66  throw new NoSuchEntityException(__('Cannot find predefined integration user!'));
67  }
68  $integrationData = $this->getIntegrationData(Integration::STATUS_ACTIVE);
69  $integrationData['integration_id'] = $integration->getId();
70  $this->integrationService->update($integrationData);
71  return true;
72  }
__()
Definition: __.php:13

◆ generateToken()

generateToken ( )

This method execute Generate Token command and enable integration

Returns
bool|\Magento\Integration\Model\Oauth\Token

Definition at line 79 of file IntegrationManager.php.

80  {
81  $consumerId = $this->generateIntegration()->getConsumerId();
82  $accessToken = $this->oauthService->getAccessToken($consumerId);
83  if (!$accessToken && $this->oauthService->createAccessToken($consumerId, true)) {
84  $accessToken = $this->oauthService->getAccessToken($consumerId);
85  }
86  return $accessToken;
87  }

The documentation for this class was generated from the following file: