Merge pull request #13970 from eileenmcnaughton/array_format_3
[civicrm-core.git] / CRM / Extension / Mapper.php
index 8615513566bbc5fa9e738fca291139cce5849c39..358d3a9103233a37b5d8494f561de53f0298efb7 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -42,7 +42,7 @@
  * module-extensions.
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 class CRM_Extension_Mapper {
 
@@ -63,7 +63,7 @@ class CRM_Extension_Mapper {
   /**
    * @var array (key => CRM_Extension_Info)
    */
-  protected $infos = array();
+  protected $infos = [];
 
   /**
    * @var array
@@ -277,17 +277,17 @@ class CRM_Extension_Mapper {
   public function getActiveModuleFiles($fresh = FALSE) {
     $config = CRM_Core_Config::singleton();
     if ($config->isUpgradeMode() || !defined('CIVICRM_DSN')) {
-      return array(); // hmm, ok
+      return []; // hmm, ok
     }
 
     $moduleExtensions = NULL;
     if ($this->cache && !$fresh) {
-      $moduleExtensions = $this->cache->get($this->cacheKey . '/moduleFiles');
+      $moduleExtensions = $this->cache->get($this->cacheKey . '_moduleFiles');
     }
 
     if (!is_array($moduleExtensions)) {
       // Check canonical module list
-      $moduleExtensions = array();
+      $moduleExtensions = [];
       $sql = '
         SELECT full_name, file
         FROM civicrm_extension
@@ -297,25 +297,25 @@ class CRM_Extension_Mapper {
       $dao = CRM_Core_DAO::executeQuery($sql);
       while ($dao->fetch()) {
         try {
-          $moduleExtensions[] = array(
+          $moduleExtensions[] = [
             'prefix' => $dao->file,
             'filePath' => $this->keyToPath($dao->full_name),
-          );
+          ];
         }
         catch (CRM_Extension_Exception $e) {
           // Putting a stub here provides more consistency
           // in how getActiveModuleFiles when racing between
           // dirty file-removals and cache-clears.
           CRM_Core_Session::setStatus($e->getMessage(), '', 'error');
-          $moduleExtensions[] = array(
+          $moduleExtensions[] = [
             'prefix' => $dao->file,
             'filePath' => NULL,
-          );
+          ];
         }
       }
 
       if ($this->cache) {
-        $this->cache->set($this->cacheKey . '/moduleFiles', $moduleExtensions);
+        $this->cache->set($this->cacheKey . '_moduleFiles', $moduleExtensions);
       }
     }
     return $moduleExtensions;
@@ -329,7 +329,7 @@ class CRM_Extension_Mapper {
    */
   public function getActiveModuleUrls() {
     // TODO optimization/caching
-    $urls = array();
+    $urls = [];
     $urls['civicrm'] = $this->keyToUrl('civicrm');
     foreach ($this->getModules() as $module) {
       /** @var $module CRM_Core_Module */
@@ -352,7 +352,7 @@ class CRM_Extension_Mapper {
    *   Ex: array("org.foo.bar").
    */
   public function getKeysByPath($pattern) {
-    $keys = array();
+    $keys = [];
 
     if (CRM_Utils_String::endsWith($pattern, '*')) {
       $prefix = rtrim($pattern, '*');
@@ -410,7 +410,7 @@ class CRM_Extension_Mapper {
    *   CRM_Core_Module
    */
   public function getModules() {
-    $result = array();
+    $result = [];
     $dao = new CRM_Core_DAO_Extension();
     $dao->type = 'module';
     $dao->find();
@@ -458,10 +458,10 @@ class CRM_Extension_Mapper {
   }
 
   public function refresh() {
-    $this->infos = array();
+    $this->infos = [];
     $this->moduleExtensions = NULL;
     if ($this->cache) {
-      $this->cache->delete($this->cacheKey . '/moduleFiles');
+      $this->cache->delete($this->cacheKey . '_moduleFiles');
     }
     // FIXME: How can code so code wrong be so right?
     CRM_Extension_System::singleton()->getClassLoader()->refresh();