From cf81f8f4528bb96982e8ec499efba9bfb37f3697 Mon Sep 17 00:00:00 2001
From: Liam Morland <lkmorlan@uwaterloo.ca>
Date: Fri, 11 Mar 2022 20:08:46 +0000
Subject: [PATCH] ISTWCMS-5418: Only call logger() when it exists in
 UwDrushCommands::updatePermissions()

The logger() may not exist if this is called outside of Drush.
---
 src/Commands/UwDrushCommands.php | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/Commands/UwDrushCommands.php b/src/Commands/UwDrushCommands.php
index 6c16f7b4..5718b287 100644
--- a/src/Commands/UwDrushCommands.php
+++ b/src/Commands/UwDrushCommands.php
@@ -105,11 +105,16 @@ class UwDrushCommands extends DrushCommands {
       UwRoles::setUwPermissions($uw_role, $additional);
 
       // Set message for specific role setting permissions.
-      $this->logger()->success('Permissions set for ' . $uw_role['label'] . '.');
+      // The logger() may not exist if this is called outside of Drush.
+      if ($this->logger()) {
+        $this->logger()->success('Permissions set for ' . $uw_role['label'] . '.');
+      }
     }
 
     // Set message for command completed.
-    $this->logger()->success('All permissions set.');
+    if ($this->logger()) {
+      $this->logger()->success('All permissions set.');
+    }
   }
 
   /**
-- 
GitLab