From 9a5dc86456822544524041ebc5fec8055023b428 Mon Sep 17 00:00:00 2001 From: Allen Shaw Date: Mon, 26 Sep 2016 14:58:57 -0500 Subject: [PATCH] Toward CRM-19414 --- CRM/Admin/Page/Extensions.php | 38 +-------------------------- CRM/Extension/System.php | 49 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index b595b59162..257a2faac5 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -296,43 +296,7 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { * @return array */ public static function createExtendedInfo(CRM_Extension_Info $obj) { - $mapper = CRM_Extension_System::singleton()->getMapper(); - $manager = CRM_Extension_System::singleton()->getManager(); - - $extensionRow = (array) $obj; - try { - $extensionRow['path'] = $mapper->keyToBasePath($obj->key); - } - catch (CRM_Extension_Exception $e) { - $extensionRow['path'] = ''; - } - $extensionRow['status'] = $manager->getStatus($obj->key); - - switch ($extensionRow['status']) { - case CRM_Extension_Manager::STATUS_UNINSTALLED: - $extensionRow['statusLabel'] = ''; // ts('Uninstalled'); - break; - - case CRM_Extension_Manager::STATUS_DISABLED: - $extensionRow['statusLabel'] = ts('Disabled'); - break; - - case CRM_Extension_Manager::STATUS_INSTALLED: - $extensionRow['statusLabel'] = ts('Enabled'); // ts('Installed'); - break; - - case CRM_Extension_Manager::STATUS_DISABLED_MISSING: - $extensionRow['statusLabel'] = ts('Disabled (Missing)'); - break; - - case CRM_Extension_Manager::STATUS_INSTALLED_MISSING: - $extensionRow['statusLabel'] = ts('Enabled (Missing)'); // ts('Installed'); - break; - - default: - $extensionRow['statusLabel'] = '(' . $extensionRow['status'] . ')'; - } - return $extensionRow; + return CRM_Extension_System::createExtendedInfo($obj); } } diff --git a/CRM/Extension/System.php b/CRM/Extension/System.php index 98937ff274..e117ebc5c5 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -285,4 +285,53 @@ class CRM_Extension_System { return $this->_repoUrl; } + /** + * Take an extension's raw XML info and add information about the + * extension's status on the local system. + * + * The result format resembles the old CRM_Core_Extensions_Extension. + * + * @param CRM_Extension_Info $obj + * + * @return array + */ + public static function createExtendedInfo(CRM_Extension_Info $obj) { + $mapper = CRM_Extension_System::singleton()->getMapper(); + $manager = CRM_Extension_System::singleton()->getManager(); + + $extensionRow = (array) $obj; + try { + $extensionRow['path'] = $mapper->keyToBasePath($obj->key); + } + catch (CRM_Extension_Exception $e) { + $extensionRow['path'] = ''; + } + $extensionRow['status'] = $manager->getStatus($obj->key); + + switch ($extensionRow['status']) { + case CRM_Extension_Manager::STATUS_UNINSTALLED: + $extensionRow['statusLabel'] = ''; // ts('Uninstalled'); + break; + + case CRM_Extension_Manager::STATUS_DISABLED: + $extensionRow['statusLabel'] = ts('Disabled'); + break; + + case CRM_Extension_Manager::STATUS_INSTALLED: + $extensionRow['statusLabel'] = ts('Enabled'); // ts('Installed'); + break; + + case CRM_Extension_Manager::STATUS_DISABLED_MISSING: + $extensionRow['statusLabel'] = ts('Disabled (Missing)'); + break; + + case CRM_Extension_Manager::STATUS_INSTALLED_MISSING: + $extensionRow['statusLabel'] = ts('Enabled (Missing)'); // ts('Installed'); + break; + + default: + $extensionRow['statusLabel'] = '(' . $extensionRow['status'] . ')'; + } + return $extensionRow; + } } -- 2.25.1