CiviCase - Optimize managed reconcile
authorcolemanw <coleman@civicrm.org>
Fri, 15 Sep 2023 13:36:11 +0000 (09:36 -0400)
committercolemanw <coleman@civicrm.org>
Fri, 15 Sep 2023 16:00:07 +0000 (12:00 -0400)
CRM/Case/ManagedEntities.php
ext/civi_case/civi_case.php

index 4f253e430efe3ffd5c55086217cef8315c5b6af3..6c6d3d1f834f70c2fc29abe8c7bb16949f13b476 100644 (file)
@@ -58,12 +58,11 @@ class CRM_Case_ManagedEntities {
    * Get a list of managed activity-types by searching CiviCase XML files.
    *
    * @param \CRM_Case_XMLRepository $xmlRepo
-   * @param \CRM_Core_ManagedEntities $me
    *
    * @return array
    * @see CRM_Utils_Hook::managed
    */
-  public static function createManagedActivityTypes(CRM_Case_XMLRepository $xmlRepo, CRM_Core_ManagedEntities $me) {
+  public static function createManagedActivityTypes(CRM_Case_XMLRepository $xmlRepo): array {
     $result = [];
     $validActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
 
@@ -102,12 +101,11 @@ class CRM_Case_ManagedEntities {
    * Get a list of managed relationship-types by searching CiviCase XML files.
    *
    * @param \CRM_Case_XMLRepository $xmlRepo
-   * @param \CRM_Core_ManagedEntities $me
    *
    * @return array
    * @see CRM_Utils_Hook::managed
    */
-  public static function createManagedRelationshipTypes(CRM_Case_XMLRepository $xmlRepo, CRM_Core_ManagedEntities $me) {
+  public static function createManagedRelationshipTypes(CRM_Case_XMLRepository $xmlRepo): array {
     $result = [];
 
     if (!isset(Civi::$statics[__CLASS__]['reltypes'])) {
index 82665f72e333d0451bd820c4b11132d9c47b73a6..d35d421086a2dd163941191a71627f67f29475d4 100644 (file)
@@ -7,10 +7,13 @@ use CRM_Case_ExtensionUtil as E;
  * Implements hook_civicrm_managed().
  */
 function civi_case_civicrm_managed(&$entities, $modules) {
-  // Don't optimize for $modules because the below functions delegate to other extensions
-  $entities = array_merge($entities,
-    CRM_Case_ManagedEntities::createManagedCaseTypes(),
-    CRM_Case_ManagedEntities::createManagedActivityTypes(CRM_Case_XMLRepository::singleton(), CRM_Core_ManagedEntities::singleton()),
-    CRM_Case_ManagedEntities::createManagedRelationshipTypes(CRM_Case_XMLRepository::singleton(), CRM_Core_ManagedEntities::singleton())
-  );
+  // Don't optimize for $modules because `createManagedCaseTypes` delegates to other extensions
+  $entities = array_merge($entities, CRM_Case_ManagedEntities::createManagedCaseTypes());
+  // These functions always declare module = civicrm
+  if (!$modules || in_array('civicrm', $modules, TRUE)) {
+    $entities = array_merge($entities,
+      CRM_Case_ManagedEntities::createManagedActivityTypes(CRM_Case_XMLRepository::singleton()),
+      CRM_Case_ManagedEntities::createManagedRelationshipTypes(CRM_Case_XMLRepository::singleton())
+    );
+  }
 }