Afform - simplify code to check if ext enabled
authorColeman Watts <coleman@civicrm.org>
Thu, 4 Mar 2021 13:30:43 +0000 (08:30 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 6 Mar 2021 15:49:33 +0000 (10:49 -0500)
ext/search/Civi/Search/Admin.php

index 711a8378ca16fbd44f4b1defc10706eb5280fc28..a03eb28761f96105c8355e4b1d19d4b2980fceef 100644 (file)
@@ -24,6 +24,7 @@ class Admin {
    */
   public static function getAdminSettings():array {
     $schema = self::getSchema();
+    $extensions = \CRM_Extension_System::singleton()->getMapper();
     return [
       'schema' => $schema,
       'joins' => self::getJoins(array_column($schema, NULL, 'name')),
@@ -31,14 +32,8 @@ class Admin {
       'functions' => \CRM_Api4_Page_Api4Explorer::getSqlFunctions(),
       'displayTypes' => Display::getDisplayTypes(['id', 'name', 'label', 'description', 'icon']),
       'styles' => \CRM_Utils_Array::makeNonAssociative(self::getStyles()),
-      'afformEnabled' => (bool) \CRM_Utils_Array::findAll(
-        \CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(),
-        ['fullName' => 'org.civicrm.afform']
-      ),
-      'afformAdminEnabled' => (bool) \CRM_Utils_Array::findAll(
-        \CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(),
-        ['fullName' => 'org.civicrm.afform_admin']
-      ),
+      'afformEnabled' => $extensions->isActiveModule('afform'),
+      'afformAdminEnabled' => $extensions->isActiveModule('afform_admin'),
     ];
   }