From: Tim Otten Date: Sat, 15 Oct 2016 11:26:25 +0000 (+0100) Subject: CRM_Admin_Page_Extensions - Extract functions format(Local,Remote)ExtensionRows X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=616aa7a1e8ffd94f19114f9360aa654da4d7f1c4;p=civicrm-core.git CRM_Admin_Page_Extensions - Extract functions format(Local,Remote)ExtensionRows --- diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index 589b9dfde6..363f35bd7a 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -125,8 +125,6 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { * Browse all options. */ public function browse() { - $mapper = CRM_Extension_System::singleton()->getMapper(); - $manager = CRM_Extension_System::singleton()->getManager(); // build announcements at the top of the page $this->assign('extAddNewEnabled', CRM_Extension_System::singleton()->getBrowser()->isEnabled()); @@ -145,7 +143,23 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { // TODO: Debate whether to immediately detect changes in underlying source tree // $manager->refresh(); - // build list of local extensions + $localExtensionRows = $this->formatLocalExtensionRows(); + $this->assign('localExtensionRows', $localExtensionRows); + + $remoteExtensionRows = $this->formatRemoteExtensionRows($localExtensionRows); + $this->assign('remoteExtensionRows', $remoteExtensionRows); + } + + /** + * Get the list of local extensions and format them as a table with + * status and action data. + * + * @return array + */ + public function formatLocalExtensionRows() { + $mapper = CRM_Extension_System::singleton()->getMapper(); + $manager = CRM_Extension_System::singleton()->getManager(); + $localExtensionRows = array(); // array($pseudo_id => extended_CRM_Extension_Info) $keys = array_keys($manager->getStatuses()); sort($keys); @@ -203,8 +217,17 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { $localExtensionRows[$row['id']] = $row; } - $this->assign('localExtensionRows', $localExtensionRows); + return $localExtensionRows; + } + /** + * Get the list of local extensions and format them as a table with + * status and action data. + * + * @param array $localExtensionRows + * @return array + */ + public function formatRemoteExtensionRows($localExtensionRows) { try { $remoteExtensions = CRM_Extension_System::singleton()->getBrowser()->getExtensions(); } @@ -238,7 +261,8 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { } $remoteExtensionRows[$row['id']] = $row; } - $this->assign('remoteExtensionRows', $remoteExtensionRows); + + return $remoteExtensionRows; } /**