Skip to content

Commit 1bf8395

Browse files
authored
Merge pull request #444 from magento-performance/CABPI-396
CABPI-396: Change public methods that are used only inside the class to private
2 parents 54e1a52 + 66d688d commit 1bf8395

38 files changed

+234
-251
lines changed

app/code/Magento/AdminAdobeIms/Block/Adminhtml/ImsReAuth.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@
77

88
namespace Magento\AdminAdobeIms\Block\Adminhtml;
99

10-
use Magento\AdminAdobeIms\Model\Auth;
1110
use Magento\AdminAdobeIms\Service\ImsConfig;
1211
use Magento\AdobeImsApi\Api\ConfigProviderInterface;
13-
use Magento\AdobeImsApi\Api\ConfigInterface;
14-
use Magento\AdobeImsApi\Api\UserAuthorizedInterface;
15-
use Magento\AdobeImsApi\Api\UserProfileRepositoryInterface;
16-
use Magento\Authorization\Model\UserContextInterface;
1712
use Magento\Backend\Block\Template;
1813
use Magento\Backend\Block\Template\Context;
19-
use Magento\Framework\Exception\NoSuchEntityException;
2014
use Magento\Framework\Serialize\Serializer\JsonHexTag;
2115

2216
/**
@@ -38,7 +32,7 @@ class ImsReAuth extends Template
3832
/**
3933
* @var ImsConfig
4034
*/
41-
private $imsConfig;
35+
private $adminImsConfig;
4236

4337
/**
4438
* JsonHexTag Serializer Instance
@@ -51,17 +45,17 @@ class ImsReAuth extends Template
5145
* SignIn constructor.
5246
*
5347
* @param Context $context
54-
* @param ImsConfig $imsConfig
48+
* @param ImsConfig $adminImsConfig
5549
* @param JsonHexTag $json
5650
* @param array $data
5751
*/
5852
public function __construct(
5953
Context $context,
60-
ImsConfig $imsConfig,
54+
ImsConfig $adminImsConfig,
6155
JsonHexTag $json,
6256
array $data = []
6357
) {
64-
$this->imsConfig = $imsConfig;
58+
$this->adminImsConfig = $adminImsConfig;
6559
$this->serializer = $json;
6660
parent::__construct($context, $data);
6761
}
@@ -92,7 +86,7 @@ private function getDefaultComponentConfig(): array
9286
'component' => self::ADOBE_IMS_JS_REAUTH,
9387
'template' => self::ADOBE_IMS_REAUTH,
9488
'loginConfig' => [
95-
'url' => $this->imsConfig->getAdminAdobeImsReAuthUrl(),
89+
'url' => $this->adminImsConfig->getAdminAdobeImsReAuthUrl(),
9690
'callbackParsingParams' => [
9791
'regexpPattern' => self::RESPONSE_REGEXP_PATTERN,
9892
'codeIndex' => self::RESPONSE_CODE_INDEX,

app/code/Magento/AdminAdobeIms/Block/Adminhtml/System/Config/Form/Field/Disabled.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
class Disabled extends Field
1818
{
1919
/** @var ImsConfig */
20-
private ImsConfig $imsConfig;
20+
private ImsConfig $adminImsConfig;
2121

2222
/**
2323
* @param Context $context
2424
* @param SecureHtmlRenderer $secureRenderer
25-
* @param ImsConfig $imsConfig
25+
* @param ImsConfig $adminImsConfig
2626
* @param array $data
2727
*/
2828
public function __construct(
2929
Context $context,
3030
SecureHtmlRenderer $secureRenderer,
31-
ImsConfig $imsConfig,
31+
ImsConfig $adminImsConfig,
3232
array $data = []
3333
) {
3434
parent::__construct($context, $data, $secureRenderer);
35-
$this->imsConfig = $imsConfig;
35+
$this->adminImsConfig = $adminImsConfig;
3636
}
3737

3838
/**
@@ -43,7 +43,7 @@ public function __construct(
4343
*/
4444
public function render(AbstractElement $element): string
4545
{
46-
if ($this->imsConfig->enabled() === false) {
46+
if ($this->adminImsConfig->enabled() === false) {
4747
return parent::render($element);
4848
}
4949
return '';

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsDisableCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ class AdminAdobeImsDisableCommand extends Command
2424
/**
2525
* @var ImsConfig
2626
*/
27-
private ImsConfig $imsConfig;
27+
private ImsConfig $adminImsConfig;
2828

2929
/**
3030
* @var TypeListInterface
3131
*/
3232
private TypeListInterface $cacheTypeList;
3333

3434
/**
35-
* @param ImsConfig $imsConfig
35+
* @param ImsConfig $adminImsConfig
3636
* @param TypeListInterface $cacheTypeList
3737
*/
3838
public function __construct(
39-
ImsConfig $imsConfig,
39+
ImsConfig $adminImsConfig,
4040
TypeListInterface $cacheTypeList
4141
) {
4242
parent::__construct();
43-
$this->imsConfig = $imsConfig;
43+
$this->adminImsConfig = $adminImsConfig;
4444

4545
$this->setName('admin:adobe-ims:disable')
4646
->setDescription('Disable Adobe IMS Module');
@@ -53,7 +53,7 @@ public function __construct(
5353
protected function execute(InputInterface $input, OutputInterface $output): ?int
5454
{
5555
try {
56-
$this->imsConfig->disableModule();
56+
$this->adminImsConfig->disableModule();
5757
$this->cacheTypeList->cleanType(Config::TYPE_IDENTIFIER);
5858
$output->writeln(__('Admin Adobe IMS integration is disabled'));
5959

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsEnableCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ class AdminAdobeImsEnableCommand extends Command
5151
/**
5252
* @var ImsConfig
5353
*/
54-
private ImsConfig $imsConfig;
54+
private ImsConfig $adminImsConfig;
5555

5656
/**
5757
* @var ImsConnection
5858
*/
59-
private ImsConnection $imsConnection;
59+
private ImsConnection $adminImsConnection;
6060

6161
/**
6262
* @var ImsCommandOptionService
@@ -74,22 +74,22 @@ class AdminAdobeImsEnableCommand extends Command
7474
private UpdateTokensService $updateTokensService;
7575

7676
/**
77-
* @param ImsConfig $imsConfig
78-
* @param ImsConnection $imsConnection
77+
* @param ImsConfig $adminImsConfig
78+
* @param ImsConnection $adminImsConnection
7979
* @param ImsCommandOptionService $imsCommandOptionService
8080
* @param TypeListInterface $cacheTypeList
8181
* @param UpdateTokensService $updateTokensService
8282
*/
8383
public function __construct(
84-
ImsConfig $imsConfig,
85-
ImsConnection $imsConnection,
84+
ImsConfig $adminImsConfig,
85+
ImsConnection $adminImsConnection,
8686
ImsCommandOptionService $imsCommandOptionService,
8787
TypeListInterface $cacheTypeList,
8888
UpdateTokensService $updateTokensService
8989
) {
9090
parent::__construct();
91-
$this->imsConfig = $imsConfig;
92-
$this->imsConnection = $imsConnection;
91+
$this->adminImsConfig = $adminImsConfig;
92+
$this->adminImsConnection = $adminImsConnection;
9393
$this->imsCommandOptionService = $imsCommandOptionService;
9494
$this->cacheTypeList = $cacheTypeList;
9595
$this->updateTokensService = $updateTokensService;
@@ -198,9 +198,9 @@ private function enableModule(
198198
string $organizationId,
199199
bool $isTwoFactorAuthEnabled
200200
): bool {
201-
$testAuth = $this->imsConnection->testAuth($clientId);
201+
$testAuth = $this->adminImsConnection->testAuth($clientId);
202202
if ($testAuth) {
203-
$this->imsConfig->enableModule($clientId, $clientSecret, $organizationId, $isTwoFactorAuthEnabled);
203+
$this->adminImsConfig->enableModule($clientId, $clientSecret, $organizationId, $isTwoFactorAuthEnabled);
204204
$this->cacheTypeList->cleanType(Config::TYPE_IDENTIFIER);
205205
$this->updateTokensService->execute();
206206

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsInfoCommand.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ class AdminAdobeImsInfoCommand extends Command
3838
/**
3939
* @var ImsConfig
4040
*/
41-
private ImsConfig $imsConfig;
41+
private ImsConfig $adminImsConfig;
4242

4343
/**
4444
* @var ImsConnection
4545
*/
46-
private ImsConnection $imsConnection;
46+
private ImsConnection $adminImsConnection;
4747

4848
/**
49-
* @param ImsConfig $imsConfig
50-
* @param ImsConnection $imsConnection
49+
* @param ImsConfig $adminImsConfig
50+
* @param ImsConnection $adminImsConnection
5151
*/
5252
public function __construct(
53-
ImsConfig $imsConfig,
54-
ImsConnection $imsConnection
53+
ImsConfig $adminImsConfig,
54+
ImsConnection $adminImsConnection
5555
) {
5656
parent::__construct();
57-
$this->imsConfig = $imsConfig;
58-
$this->imsConnection = $imsConnection;
57+
$this->adminImsConfig = $adminImsConfig;
58+
$this->adminImsConnection = $adminImsConnection;
5959

6060
$this->setName('admin:adobe-ims:info')
6161
->setDescription('Information of Adobe IMS Module configuration');
@@ -67,12 +67,12 @@ public function __construct(
6767
protected function execute(InputInterface $input, OutputInterface $output): ?int
6868
{
6969
try {
70-
if ($this->imsConfig->enabled()) {
71-
$clientId = $this->imsConfig->getApiKey();
72-
if ($this->imsConnection->testAuth($clientId)) {
73-
$clientSecret = $this->imsConfig->getPrivateKey() ? 'configured' : 'not configured';
70+
if ($this->adminImsConfig->enabled()) {
71+
$clientId = $this->adminImsConfig->getApiKey();
72+
if ($this->adminImsConnection->testAuth($clientId)) {
73+
$clientSecret = $this->adminImsConfig->getPrivateKey() ? 'configured' : 'not configured';
7474
$output->writeln(self::CLIENT_ID_NAME . ': ' . $clientId);
75-
$output->writeln(self::ORGANIZATION_ID_NAME . ': ' . $this->imsConfig->getOrganizationId());
75+
$output->writeln(self::ORGANIZATION_ID_NAME . ': ' . $this->adminImsConfig->getOrganizationId());
7676
$output->writeln(self::CLIENT_SECRET_NAME . ' ' . $clientSecret);
7777
}
7878
} else {

app/code/Magento/AdminAdobeIms/Console/Command/AdminAdobeImsStatusCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ class AdminAdobeImsStatusCommand extends Command
2525
/**
2626
* @var ImsConfig
2727
*/
28-
private ImsConfig $imsConfig;
28+
private ImsConfig $adminImsConfig;
2929

3030
/**
31-
* @param ImsConfig $imsConfig
31+
* @param ImsConfig $adminImsConfig
3232
*/
3333
public function __construct(
34-
ImsConfig $imsConfig
34+
ImsConfig $adminImsConfig
3535
) {
3636
parent::__construct();
37-
$this->imsConfig = $imsConfig;
37+
$this->adminImsConfig = $adminImsConfig;
3838

3939
$this->setName('admin:adobe-ims:status')
4040
->setDescription('Status of Adobe IMS Module');
@@ -66,6 +66,6 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
6666
*/
6767
private function getModuleStatus(): string
6868
{
69-
return $this->imsConfig->enabled() ? self::MODE_ENABLE .'d' : self::MODE_DISABLE.'d';
69+
return $this->adminImsConfig->enabled() ? self::MODE_ENABLE .'d' : self::MODE_DISABLE.'d';
7070
}
7171
}

app/code/Magento/AdminAdobeIms/Controller/Adminhtml/OAuth/ImsCallback.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ class ImsCallback extends Auth implements HttpGetActionInterface
2929
/**
3030
* @var ImsConnection
3131
*/
32-
private ImsConnection $imsConnection;
32+
private ImsConnection $adminImsConnection;
3333

3434
/**
3535
* @var ImsConfig
3636
*/
37-
private ImsConfig $imsConfig;
37+
private ImsConfig $adminImsConfig;
3838

3939
/**
4040
* @var ImsOrganizationService
4141
*/
42-
private ImsOrganizationService $organizationService;
42+
private ImsOrganizationService $adminOrganizationService;
4343

4444
/**
4545
* @var AdminLoginProcessService
@@ -53,24 +53,24 @@ class ImsCallback extends Auth implements HttpGetActionInterface
5353

5454
/**
5555
* @param Context $context
56-
* @param ImsConnection $imsConnection
57-
* @param ImsConfig $imsConfig
58-
* @param ImsOrganizationService $organizationService
56+
* @param ImsConnection $adminImsConnection
57+
* @param ImsConfig $adminImsConfig
58+
* @param ImsOrganizationService $adminOrganizationService
5959
* @param AdminLoginProcessService $adminLoginProcessService
6060
* @param AdminAdobeImsLogger $logger
6161
*/
6262
public function __construct(
6363
Context $context,
64-
ImsConnection $imsConnection,
65-
ImsConfig $imsConfig,
66-
ImsOrganizationService $organizationService,
64+
ImsConnection $adminImsConnection,
65+
ImsConfig $adminImsConfig,
66+
ImsOrganizationService $adminOrganizationService,
6767
AdminLoginProcessService $adminLoginProcessService,
6868
AdminAdobeImsLogger $logger
6969
) {
7070
parent::__construct($context);
71-
$this->imsConnection = $imsConnection;
72-
$this->imsConfig = $imsConfig;
73-
$this->organizationService = $organizationService;
71+
$this->adminImsConnection = $adminImsConnection;
72+
$this->adminImsConfig = $adminImsConfig;
73+
$this->adminOrganizationService = $adminOrganizationService;
7474
$this->adminLoginProcessService = $adminLoginProcessService;
7575
$this->logger = $logger;
7676
}
@@ -86,7 +86,7 @@ public function execute(): Redirect
8686
$resultRedirect = $this->resultRedirectFactory->create();
8787
$resultRedirect->setPath($this->_helper->getHomePageUrl());
8888

89-
if (!$this->imsConfig->enabled()) {
89+
if (!$this->adminImsConfig->enabled()) {
9090
$this->getMessageManager()->addErrorMessage('Adobe Sign-In is disabled.');
9191
return $resultRedirect;
9292
}
@@ -98,13 +98,13 @@ public function execute(): Redirect
9898
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
9999
}
100100

101-
$tokenResponse = $this->imsConnection->getTokenResponse($code);
101+
$tokenResponse = $this->adminImsConnection->getTokenResponse($code);
102102

103-
$profile = $this->imsConnection->getProfile($tokenResponse->getAccessToken());
103+
$profile = $this->adminImsConnection->getProfile($tokenResponse->getAccessToken());
104104
if (empty($profile['email'])) {
105105
throw new AuthenticationException(__('An authentication error occurred. Verify and try again.'));
106106
}
107-
$this->organizationService->checkOrganizationAllocation($profile);
107+
$this->adminOrganizationService->checkOrganizationAllocation($profile);
108108
$this->adminLoginProcessService->execute($tokenResponse, $profile);
109109
} catch (AdobeImsAuthorizationException $e) {
110110
$this->logger->error($e->getMessage());

0 commit comments

Comments
 (0)