Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OauthUserContext.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Framework\Oauth\Helper\Request as OauthRequestHelper;
11 use Magento\Framework\Oauth\OauthInterface as OauthService;
14 
19 {
23  protected $request;
24 
29 
33  protected $oauthService;
34 
38  protected $oauthHelper;
39 
43  protected $integrationId;
44 
53  public function __construct(
56  OauthService $oauthService,
57  OauthRequestHelper $oauthHelper
58  ) {
59  $this->request = $request;
60  $this->integrationService = $integrationService;
61  $this->oauthService = $oauthService;
62  $this->oauthHelper = $oauthHelper;
63  }
64 
68  public function getUserId()
69  {
70  if ($this->integrationId) {
71  return $this->integrationId;
72  }
73  $oauthRequest = $this->oauthHelper->prepareRequest($this->request);
74  //If its not a valid Oauth request no further processing is needed
75  if (empty($oauthRequest)) {
76  return null;
77  }
78  $consumerId = $this->oauthService->validateAccessTokenRequest(
79  $oauthRequest,
80  $this->oauthHelper->getRequestUrl($this->request),
81  $this->request->getMethod()
82  );
83  $integration = $this->integrationService->findActiveIntegrationByConsumerId($consumerId);
84  return $this->integrationId = ($integration->getId() ? (int)$integration->getId() : null);
85  }
86 
90  public function getUserType()
91  {
93  }
94 }
__construct(Request $request, IntegrationServiceInterface $integrationService, OauthService $oauthService, OauthRequestHelper $oauthHelper)