From: Tim Otten Date: Tue, 6 Jan 2015 21:10:53 +0000 (-0800) Subject: INFRA-132 - CRM/Extension - phpcbf X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b3a4b87978b9baa27b17d749d6a7370fd1054c7a;p=civicrm-core.git INFRA-132 - CRM/Extension - phpcbf --- diff --git a/CRM/Extension/Downloader.php b/CRM/Extension/Downloader.php index 054b6b6419..b8f152e3b0 100644 --- a/CRM/Extension/Downloader.php +++ b/CRM/Extension/Downloader.php @@ -144,6 +144,7 @@ class CRM_Extension_Downloader { switch ($result) { case CRM_Utils_HttpClient::STATUS_OK: return TRUE; + default: return FALSE; } diff --git a/CRM/Extension/Manager.php b/CRM/Extension/Manager.php index 86a897d3e8..db6716c8e0 100644 --- a/CRM/Extension/Manager.php +++ b/CRM/Extension/Manager.php @@ -150,17 +150,20 @@ class CRM_Extension_Manager { ))); } break; + case self::STATUS_INSTALLED_MISSING: case self::STATUS_DISABLED_MISSING: - // the extension does not exist in any container; we're free to put it anywhere + // the extension does not exist in any container; we're free to put it anywhere $tgtPath = $this->defaultContainer->getBaseDir() . DIRECTORY_SEPARATOR . $newInfo->key; list ($oldInfo, $typeManager) = $this->_getMissingInfoTypeHandler($newInfo->key); // throws Exception break; + case self::STATUS_UNKNOWN: - // the extension does not exist in any container; we're free to put it anywhere + // the extension does not exist in any container; we're free to put it anywhere $tgtPath = $this->defaultContainer->getBaseDir() . DIRECTORY_SEPARATOR . $newInfo->key; $oldInfo = $typeManager = NULL; break; + default: throw new CRM_Extension_Exception("Cannot install or enable extension: {$newInfo->key}"); } @@ -174,6 +177,7 @@ class CRM_Extension_Manager { throw new CRM_Extension_Exception("Failed to move $tmpCodeDir to $tgtPath"); } break; + case self::STATUS_INSTALLED: case self::STATUS_INSTALLED_MISSING: case self::STATUS_DISABLED: @@ -186,6 +190,7 @@ class CRM_Extension_Manager { $this->_updateExtensionEntry($newInfo); $typeManager->onPostReplace($oldInfo, $newInfo); break; + default: throw new CRM_Extension_Exception("Cannot install or enable extension: {$newInfo->key}"); } @@ -215,18 +220,21 @@ class CRM_Extension_Manager { case self::STATUS_INSTALLED: // ok, nothing to do break; + case self::STATUS_DISABLED: // re-enable it $typeManager->onPreEnable($info); $this->_setExtensionActive($info, 1); $typeManager->onPostEnable($info); break; + case self::STATUS_UNINSTALLED: // install anew $typeManager->onPreInstall($info); $this->_createExtensionEntry($info); $typeManager->onPostInstall($info); break; + case self::STATUS_UNKNOWN: default: throw new CRM_Extension_Exception("Cannot install or enable extension: $key"); @@ -245,13 +253,16 @@ class CRM_Extension_Manager { case self::STATUS_INSTALLED: // ok, nothing to do break; + case self::STATUS_DISABLED: // re-enable it break; + case self::STATUS_UNINSTALLED: // install anew $typeManager->onPostPostInstall($info); break; + case self::STATUS_UNKNOWN: default: throw new CRM_Extension_Exception("Cannot install or enable extension: $key"); @@ -294,17 +305,20 @@ class CRM_Extension_Manager { $this->_setExtensionActive($info, 0); $typeManager->onPostDisable($info); break; + case self::STATUS_INSTALLED_MISSING: list ($info, $typeManager) = $this->_getMissingInfoTypeHandler($key); // throws Exception $typeManager->onPreDisable($info); $this->_setExtensionActive($info, 0); $typeManager->onPostDisable($info); break; + case self::STATUS_DISABLED: case self::STATUS_DISABLED_MISSING: case self::STATUS_UNINSTALLED: // ok, nothing to do break; + case self::STATUS_UNKNOWN: default: throw new CRM_Extension_Exception("Cannot disable unknown extension: $key"); @@ -332,27 +346,31 @@ class CRM_Extension_Manager { // TODO: to mitigate the risk of crashing during installation, scan // keys/statuses/types before doing anything - foreach ($keys as $key) { + foreach ($keys as $key) { switch ($origStatuses[$key]) { case self::STATUS_INSTALLED: case self::STATUS_INSTALLED_MISSING: throw new CRM_Extension_Exception("Cannot uninstall extension; disable it first: $key"); - break; + + break; case self::STATUS_DISABLED: list ($info, $typeManager) = $this->_getInfoTypeHandler($key); // throws Exception $typeManager->onPreUninstall($info); $this->_removeExtensionEntry($info); $typeManager->onPostUninstall($info); break; + case self::STATUS_DISABLED_MISSING: list ($info, $typeManager) = $this->_getMissingInfoTypeHandler($key); // throws Exception $typeManager->onPreUninstall($info); $this->_removeExtensionEntry($info); $typeManager->onPostUninstall($info); break; + case self::STATUS_UNINSTALLED: // ok, nothing to do break; + case self::STATUS_UNKNOWN: default: throw new CRM_Extension_Exception("Cannot disable unknown extension: $key"); diff --git a/CRM/Extension/Manager/Payment.php b/CRM/Extension/Manager/Payment.php index 3dd9c27a2a..02b879f2d2 100644 --- a/CRM/Extension/Manager/Payment.php +++ b/CRM/Extension/Manager/Payment.php @@ -36,7 +36,7 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { /** - @var CRM_Extension_Mapper + @var CRM_Extension_Mapper */ protected $mapper; @@ -235,7 +235,7 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { 1 => array($info->name, 'String'), ) ); - if ($dao->fetch()) $paymentProcessor = array( + if ($dao->fetch()) { $paymentProcessor = array( 'id' => -1, 'name' => $dao->title, 'payment_processor_type_id' => $dao->id, @@ -251,8 +251,10 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { 'is_recur' => $dao->is_recur, 'billing_mode' => $dao->billing_mode, 'payment_type' => $dao->payment_type, - ); - else CRM_Core_Error::fatal("Unable to find payment processor in " . __CLASS__ . '::' . __METHOD__); + ); + } + else { CRM_Core_Error::fatal("Unable to find payment processor in " . __CLASS__ . '::' . __METHOD__); + } } // In the case of uninstall, check for instances of PP first. @@ -280,7 +282,7 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { default: CRM_Core_Session::setStatus(ts( "Unrecognized payment hook (%1) in %2::%3", - array(1 => $method, 2 => __CLASS__ , 3 => __METHOD__) ), + array(1 => $method, 2 => __CLASS__ , 3 => __METHOD__) ), '', 'error'); } } diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index 593429c873..fdf7c3c2ae 100755 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -102,10 +102,10 @@ class CRM_Extension_Mapper { $this->civicrmUrl = rtrim($config->resourceBase, '/'); } if ($civicrmPath) { - $this->civicrmPath = rtrim($civicrmPath,'/'); + $this->civicrmPath = rtrim($civicrmPath, '/'); } else { global $civicrm_root; - $this->civicrmPath = rtrim($civicrm_root,'/'); + $this->civicrmPath = rtrim($civicrm_root, '/'); } } diff --git a/CRM/Extension/System.php b/CRM/Extension/System.php index a2714840e5..405be00550 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -235,8 +235,8 @@ class CRM_Extension_System { // boolean false means don't try to check extensions // http://issues.civicrm.org/jira/browse/CRM-10575 - if($url === false) { - $this->_repoUrl = false; + if($url === FALSE) { + $this->_repoUrl = FALSE; } else { $this->_repoUrl = CRM_Utils_System::evalUrl($url);