Merge pull request #20561 from WeMoveEU/fix/double-autosave
[civicrm-core.git] / CRM / Extension / Browser.php
index 89994cb00ebee2c52960bd74e7986feb65cdb208..62d1b25bf9910b7bb3370b5716106bd3ee00fad0 100644 (file)
@@ -94,10 +94,10 @@ class CRM_Extension_Browser {
    */
   public function checkRequirements() {
     if (!$this->isEnabled()) {
-      return array();
+      return [];
     }
 
-    $errors = array();
+    $errors = [];
 
     if (!$this->cacheDir || !is_dir($this->cacheDir) || !is_writable($this->cacheDir)) {
       $civicrmDestination = urlencode(CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'));
@@ -119,15 +119,15 @@ class CRM_Extension_Browser {
   /**
    * Get a list of all available extensions.
    *
-   * @return array
+   * @return CRM_Extension_Info[]
    *   ($key => CRM_Extension_Info)
    */
   public function getExtensions() {
     if (!$this->isEnabled() || count($this->checkRequirements())) {
-      return array();
+      return [];
     }
 
-    $exts = array();
+    $exts = [];
 
     $remote = $this->_discoverRemote();
     if (is_array($remote)) {
@@ -159,7 +159,7 @@ class CRM_Extension_Browser {
   }
 
   /**
-   * @return array
+   * @return CRM_Extension_Info[]
    * @throws CRM_Extension_Exception_ParseException
    */
   private function _discoverRemote() {
@@ -180,7 +180,7 @@ class CRM_Extension_Browser {
       $remotes = json_decode($this->grabCachedJson(), TRUE);
     }
 
-    $this->_remotesDiscovered = array();
+    $this->_remotesDiscovered = [];
     foreach ((array) $remotes as $id => $xml) {
       $ext = CRM_Extension_Info::loadFromString($xml);
       $this->_remotesDiscovered[] = $ext;
@@ -230,7 +230,7 @@ class CRM_Extension_Browser {
     if (FALSE === $this->getRepositoryUrl()) {
       // don't check if the user has configured civi not to check an external
       // url for extensions. See CRM-10575.
-      return array();
+      return [];
     }
 
     $filename = $this->cacheDir . DIRECTORY_SEPARATOR . self::CACHE_JSON_FILE . '.' . md5($this->getRepositoryUrl());
@@ -243,7 +243,7 @@ class CRM_Extension_Browser {
     restore_error_handler();
 
     if ($status !== CRM_Utils_HttpClient::STATUS_OK) {
-      throw new CRM_Extension_Exception(ts('The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests or contact CiviCRM team on <a href="http://forum.civicrm.org/">CiviCRM forum</a>.', array(1 => $this->getRepositoryUrl())), 'connection_error');
+      throw new CRM_Extension_Exception(ts('The CiviCRM public extensions directory at %1 could not be contacted - please check your webserver can make external HTTP requests. Contact your site administrator for assistance.', [1 => $this->getRepositoryUrl()]), 'connection_error');
     }
 
     // Don't call grabCachedJson here, that would risk infinite recursion