- protected function getManagedEntities(array $filters = []): array {
- $return = [];
- foreach ($this->managedActions as $actionKey => $action) {
- foreach ($filters as $filterKey => $filterValue) {
- if ($action[$filterKey] !== $filterValue) {
- continue 2;
- }
- }
- $return[$actionKey] = $action;
- }
- return $return;
- }
-
- /**
- * For all disabled modules, disable any managed entities.
- */
- protected function reconcileDisabledModules() {
- if (empty($this->moduleIndex[FALSE])) {
- return;
- }
-
- $in = CRM_Core_DAO::escapeStrings(array_keys($this->moduleIndex[FALSE]));
- $dao = new CRM_Core_DAO_Managed();
- $dao->whereAdd("module in ($in)");
- $dao->orderBy('id DESC');
- $dao->find();
- while ($dao->fetch()) {
- $this->disableEntity($dao);
-
- }
- }
-
- /**
- * Remove any orphaned (stale) entities that are linked to
- * unknown modules.
- */
- protected function reconcileUnknownModules() {
- $knownModules = [];
- if (array_key_exists(0, $this->moduleIndex) && is_array($this->moduleIndex[0])) {
- $knownModules = array_merge($knownModules, array_keys($this->moduleIndex[0]));
- }
- if (array_key_exists(1, $this->moduleIndex) && is_array($this->moduleIndex[1])) {
- $knownModules = array_merge($knownModules, array_keys($this->moduleIndex[1]));
- }
-
- $dao = new CRM_Core_DAO_Managed();
- if (!empty($knownModules)) {
- $in = CRM_Core_DAO::escapeStrings($knownModules);
- $dao->whereAdd("module NOT IN ($in)");
- $dao->orderBy('id DESC');
- }
- $dao->find();
- while ($dao->fetch()) {
- $this->removeStaleEntity($dao);
- }