dev/core#4127 move mailing workflow check to userSystem
authorHerb v/d Dool <herb@3speedhub.com>
Wed, 15 Feb 2023 17:46:41 +0000 (12:46 -0500)
committerHerb v/d Dool <herb@3speedhub.com>
Thu, 16 Feb 2023 15:38:22 +0000 (10:38 -0500)
CRM/Mailing/Info.php
CRM/Utils/System/Base.php
CRM/Utils/System/Drupal8.php
CRM/Utils/System/DrupalBase.php

index e30a0dee84f4f2ec3d629da577906e197368571f..bffbd7ca798ef4b1dbb25b0dd92b8ffeb615c621 100644 (file)
@@ -159,21 +159,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
    */
   public static function workflowEnabled() {
     $config = CRM_Core_Config::singleton();
-
-    // early exit, since not true for most
-    if (!$config->userSystem->is_drupal ||
-      !function_exists('module_exists')
-    ) {
-      return FALSE;
-    }
-
-    if (!module_exists('rules')) {
-      return FALSE;
-    }
-
-    $enableWorkflow = Civi::settings()->get('civimail_workflow');
-
-    return $enableWorkflow && $config->userSystem->is_drupal;
+    return $config->userSystem->mailingWorkflowIsEnabled();
   }
 
   /**
index 3a69bc69e69a29452f21faea25e25cfb9cc06346..8ca38079aa53c81b9d83f7728dd62464d5399a94 100644 (file)
@@ -1152,4 +1152,13 @@ abstract class CRM_Utils_System_Base {
     return $_SERVER['REMOTE_ADDR'] ?? NULL;
   }
 
+  /**
+   * Check if mailing workflow is enabled
+   *
+   * @return bool
+   */
+  public function mailingWorkflowIsEnabled():bool {
+    return FALSE;
+  }
+
 }
index c4d06a5a2c1c259365af621ff2f26a2683c095f6..5d26a2533c59e705bd46e94ab2cb5a738ff4383e 100644 (file)
@@ -932,4 +932,17 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
     return class_exists('Drupal') ? \Drupal::request()->getClientIp() : ($_SERVER['REMOTE_ADDR'] ?? NULL);
   }
 
+  /**
+   * @inheritdoc
+   */
+  public function mailingWorkflowIsEnabled():bool {
+    if (!\Drupal::moduleHandler()->moduleExists('rules')) {
+      return FALSE;
+    }
+
+    $enableWorkflow = Civi::settings()->get('civimail_workflow');
+
+    return (bool) $enableWorkflow;
+  }
+
 }
index e65c03d20026f5f34920594239a2500eef31e40f..6b1b466478735b4c74ee2e6578f42fb685c9fb1a 100644 (file)
@@ -763,4 +763,17 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
     return $emailName;
   }
 
+  /**
+   * @inheritdoc
+   */
+  public function mailingWorkflowIsEnabled():bool {
+    if (!module_exists('rules')) {
+      return FALSE;
+    }
+
+    $enableWorkflow = Civi::settings()->get('civimail_workflow');
+
+    return (bool) $enableWorkflow;
+  }
+
 }