From 5099a2e5c29c6821f211eab0c919dc5fe3fdc165 Mon Sep 17 00:00:00 2001 From: protitude Date: Mon, 8 Apr 2024 18:16:28 -0600 Subject: [PATCH] drush: fix phpstan error --- drush.services.yml | 3 +++ src/Commands/OitCommands.php | 50 ++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/drush.services.yml b/drush.services.yml index 4647828..9c9ca9f 100644 --- a/drush.services.yml +++ b/drush.services.yml @@ -1,5 +1,8 @@ services: oit.commands: class: \Drupal\oit\Commands\OitCommands + arguments: + - '@servicenow.princess.list' + - '@messenger' tags: - { name: drush.command } diff --git a/src/Commands/OitCommands.php b/src/Commands/OitCommands.php index c0d4ec6..13511b0 100644 --- a/src/Commands/OitCommands.php +++ b/src/Commands/OitCommands.php @@ -3,6 +3,8 @@ namespace Drupal\oit\Commands; use Drush\Commands\DrushCommands; +use Drupal\Core\Messenger\MessengerInterface; +use Drupal\servicenow\Plugin\PrincessList; /** * Various utility commands for OIT. @@ -10,15 +12,53 @@ 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.'); } }