Skip to content

Commit 65a898a

Browse files
authored
Merge pull request #302 from epam/MDP-731-avoid-call-unexisted-service
MDP-731 - avoid call of unexisted service in powerBIConfig during err…
2 parents d422e96 + 3ac0074 commit 65a898a

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

modules/quanthub_core/quanthub_core.services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ services:
4747

4848
powerbi_embed_configs:
4949
class: Drupal\quanthub_core\PowerBIEmbedConfigs
50-
arguments: ['@config.factory', '@key.repository', '@logger.factory', '@http_client']
50+
arguments: ['@config.factory', '@logger.factory', '@http_client']
5151

5252
# User Info Cache Context based on User Info Role for anonymous and User Id for others.
5353
cache_context.user_info_attributes:

modules/quanthub_core/src/PowerBIEmbedConfigs.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Drupal\Core\Config\ConfigFactoryInterface;
66
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
7-
use Drupal\key\KeyRepositoryInterface;
87
use GuzzleHttp\ClientInterface;
98
use Jumbojett\OpenIDConnectClient;
109

@@ -20,13 +19,6 @@ class PowerBIEmbedConfigs {
2019
*/
2120
protected $configFactory;
2221

23-
/**
24-
* Key repository object.
25-
*
26-
* @var \Drupal\key\KeyRepositoryInterface
27-
*/
28-
protected $repository;
29-
3022
/**
3123
* Logger Factory.
3224
*
@@ -45,8 +37,6 @@ class PowerBIEmbedConfigs {
4537
* Constructor of PowerBIEmbedConfigs.
4638
*
4739
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
48-
* The configuration factory service.
49-
* @param \Drupal\key\KeyRepositoryInterface $repository
5040
* The key repository object.
5141
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory
5242
* The logger channel factory.
@@ -55,12 +45,10 @@ class PowerBIEmbedConfigs {
5545
*/
5646
public function __construct(
5747
ConfigFactoryInterface $configFactory,
58-
KeyRepositoryInterface $repository,
5948
LoggerChannelFactoryInterface $loggerFactory,
6049
ClientInterface $httpClient,
6150
) {
6251
$this->configFactory = $configFactory;
63-
$this->repository = $repository;
6452
$this->loggerFactory = $loggerFactory->get('powerbi_embed');
6553
$this->httpClient = $httpClient;
6654
}
@@ -97,9 +85,7 @@ public function getUsername() {
9785
* Return PowerBI configured password.
9886
*/
9987
public function getPassword() {
100-
$config_password = $this->getConfig()->get('password');
101-
$key = $this->repository->getKey($config_password);
102-
return $key?->getKeyValue();
88+
return $this->getConfig()->get('password');
10389
}
10490

10591
/**
@@ -116,7 +102,12 @@ public function getPowerBiAccessToken() {
116102
$oidc->addScope('https://analysis.windows.net/powerbi/api/.default');
117103
$oidc_response = $oidc->requestClientCredentialsToken();
118104
if (empty($oidc_response->access_token)) {
119-
$this->loggerFactory->get('powerbi_embed')->warning('Could not get access token');
105+
$this->loggerFactory->warning(
106+
'Could not get access token @context_error',
107+
[
108+
'@context_error' => print_r($oidc_response, TRUE),
109+
]
110+
);
120111
return NULL;
121112
}
122113
return $oidc_response->access_token;

0 commit comments

Comments
 (0)