Skip to content

Commit

Permalink
drush: fix phpstan error
Browse files Browse the repository at this point in the history
  • Loading branch information
protitude committed Apr 9, 2024
1 parent 52030c0 commit 5099a2e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
3 changes: 3 additions & 0 deletions drush.services.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
services:
oit.commands:
class: \Drupal\oit\Commands\OitCommands
arguments:
- '@servicenow.princess.list'
- '@messenger'
tags:
- { name: drush.command }
50 changes: 45 additions & 5 deletions src/Commands/OitCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,62 @@
namespace Drupal\oit\Commands;

use Drush\Commands\DrushCommands;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\servicenow\Plugin\PrincessList;

/**
* Various utility commands for OIT.
*/
class OitCommands extends DrushCommands {

/**
* FULL Rebuild Princess List.
* Princess List.
*
* @var \Drupal\servicenow\Plugin\PrincessList
*/
protected $princessList;

/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;

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

/**
* Rebuild Princess List.
*
* @command oit:reload-princess
* @aliases oit-rp
* @aliases oit:rp
*/
public function reloadPrincess() {
$princess = \Drupal::service('servicenow.princess.list');
$princess->reload();
$princess->cron(0);
$this->princessList->reload();
$this->messenger->addMessage('Princess List reloaded.');
$this->loadPrincess();
}


/**
* Load Princess List.
*
* @command oit:load-princess
* @aliases oit:lp
*/
public function loadPrincess() {
$this->princessList->cron(0);
$this->messenger->addMessage('Princess List Loaded.');
}

}

0 comments on commit 5099a2e

Please sign in to comment.