Skip to content

Commit

Permalink
phpstan fix
Browse files Browse the repository at this point in the history
  • Loading branch information
protitude committed Feb 26, 2025
1 parent 6a8eec8 commit 651747c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions drush.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ services:
- '@servicenow.princess.list'
- '@messenger'
- '@oit.teamsalert'
- '@database'
tags:
- { name: drush.command }
14 changes: 12 additions & 2 deletions src/Commands/OitCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Drupal\servicenow\Plugin\PrincessList;
use Drush\Commands\DrushCommands;
use Drupal\oit\Plugin\TeamsAlert;
use Drupal\Core\Database\Connection;

/**
* Various utility commands for OIT.
Expand Down Expand Up @@ -33,18 +34,27 @@ class OitCommands extends DrushCommands {
*/
protected $teamsAlert;

/**
* The Database service.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;

/**
* Construct object.
*/
public function __construct(
PrincessList $princess_list,
MessengerInterface $messenger,
TeamsAlert $teams_alert,
Connection $database,
) {
parent::__construct();
$this->princessList = $princess_list;
$this->messenger = $messenger;
$this->teamsAlert = $teams_alert;
$this->database = $database;
}

/**
Expand Down Expand Up @@ -94,7 +104,7 @@ public function sendTeamsAlert($userMessage) {
* @aliases oit:bic
*/
public function bannedIpClean($keep = 150) {
$query = \Drupal::database()->select('ban_ip', 'b');
$query = $this->database->select('ban_ip', 'b');
$query->fields('b', ['iid']);
$query->orderBy('iid', 'ASC');
$result = $query->execute()->fetchAll();
Expand All @@ -118,7 +128,7 @@ public function bannedIpClean($keep = 150) {
}

foreach ($result_remove as $row) {
\Drupal::database()->delete('ban_ip')
$this->database->delete('ban_ip')
->condition('iid', $row)
->execute();
}
Expand Down

0 comments on commit 651747c

Please sign in to comment.