Problem/Motivation

From https://git.drupalcode.org/project/eloqua_api_redux/-/jobs/1333054

$ php vendor/bin/phpstan analyze $_WEB_ROOT/modules/custom/$CI_PROJECT_NAME $PHPSTAN_CONFIGURATION --no-progress || EXIT_CODE=$?
 ------ ---------------------------------------------------------------------- 
  Line   src/Service/EloquaApiClient.php                                       
 ------ ---------------------------------------------------------------------- 
  150    \Drupal calls should be avoided in classes, use dependency injection  
         instead                                                               
 ------ ---------------------------------------------------------------------- 
 [ERROR] Found 1 error

Steps to reproduce

Run Gitlab CI

Proposed resolution

Use dependency injection

Remaining tasks

  1. Update the code
  2. Run sniffers, linters, and automated tests
  3. Test manually

User interface changes

None

API changes

None

Data model changes

None

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

PapaGrande created an issue. See original summary.

papagrande’s picture

Status: Active » Needs review
diwakar07’s picture

Status: Needs review » Reviewed & tested by the community

Hi,

I reviewed MR !7.
It successfully fixes the phpstan errors, the gitlab ci pipeline passes.
The changes are following the dependency injection.
Looks good to me.

Moving to RTBC.

papagrande’s picture

Status: Reviewed & tested by the community » Needs work

I just merged in another MR. Can someone address the merge conflicts and any new PHPStan errors?

Thanks.

papagrande’s picture

Status: Needs work » Needs review

Conflicts fixed. Please review again.

erindarri’s picture

When attempting to apply this against 2.0.x-dev, this is failing to apply for me in:

settings.php

--- src/Form/Settings.php
+++ src/Form/Settings.php
@@ -30,8 +30,10 @@ class Settings extends ConfigFormBase {
    * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
    *   Date Formatter.
    */
-  public function __construct(ConfigFactoryInterface $config_factory,
-                              DateFormatterInterface $date_formatter) {
+  public function __construct(
+    ConfigFactoryInterface $config_factory,
+    DateFormatterInterface $date_formatter,
+  ) {
     parent::__construct($config_factory);
     $this->dateFormatter = $date_formatter;
   }

and EloquaApiClient.php.

--- src/Service/EloquaApiClient.php
+++ src/Service/EloquaApiClient.php
@@ -70,16 +77,22 @@ class EloquaApiClient {
    *   A Guzzle client object.
    * @param \Drupal\Component\Datetime\TimeInterface $time
    *   Time service.
+   * @param \Drupal\eloqua_api_redux\Service\EloquaAuthFallbackInterface $authFallbackDefault
+   *   Eloqua auth fallback service.
    */
-  public function __construct(ConfigFactory $config,
-                              LoggerChannelFactoryInterface $loggerFactory,
-                              ClientFactory $httpClientFactory,
-                              TimeInterface $time) {
+  public function __construct(
+    ConfigFactory $config,
+    LoggerChannelFactoryInterface $loggerFactory,
+    ClientFactory $httpClientFactory,
+    TimeInterface $time,
+    EloquaAuthFallbackInterface $authFallbackDefault,
+  ) {
     $this->config = $config->get('eloqua_api_redux.settings');
     $this->configTokens = $config->getEditable('eloqua_api_redux.tokens');
     $this->loggerFactory = $loggerFactory;
     $this->httpClientFactory = $httpClientFactory;
     $this->time = $time;
+    $this->authFallbackDefault = $authFallbackDefault;
   }
 
   /**
erindarri’s picture

Status: Needs review » Needs work
erindarri’s picture

Status: Needs work » Reviewed & tested by the community

I applied the diff and this merges cleanly.
GitLab pipeline is still passing.

  • papagrande committed 881d32e7 on 2.0.x
    Issue #3445820 by papagrande, erindarri, diwakar07: Add back baseline...
papagrande’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @erindarri, @diwakar07

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.