Merge pull request #14170 from mlutfy/cart-emails
[civicrm-core.git] / CRM / Core / Config.php
index 320ec6d85fa8181a6f9d11a12956b0146bfcbe33..b9c632feb6d213eebb5052e0675c609507d4d42c 100644 (file)
@@ -35,6 +35,7 @@
  * @copyright CiviCRM LLC (c) 2004-2019
  */
 
+require_once 'Log.php';
 require_once 'Mail.php';
 
 require_once 'api/api.php';
@@ -101,8 +102,8 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
    */
   public static function &singleton($loadFromDB = TRUE, $force = FALSE) {
     if (self::$_singleton === NULL || $force) {
-      $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle'));
-      $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler'));
+      $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(['CRM_Core_Error', 'handle']);
+      $errorScope = CRM_Core_TemporaryErrorScope::create(['CRM_Core_Error', 'simpleHandler']);
 
       if (defined('E_DEPRECATED')) {
         error_reporting(error_reporting() & ~E_DEPRECATED);
@@ -137,7 +138,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
    * @return object
    * @see Civi::log()
    */
-  static public function &getLog() {
+  public static function &getLog() {
     if (!isset(self::$_log)) {
       self::$_log = Log::singleton('display');
     }
@@ -179,12 +180,12 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
 
     // Whether we delete/create or simply preserve directories, we should
     // certainly make sure the restrictions are enforced.
-    foreach (array(
-               $this->templateCompileDir,
-               $this->uploadDir,
-               $this->configAndLogDir,
-               $this->customFileUploadDir,
-             ) as $dir) {
+    foreach ([
+      $this->templateCompileDir,
+      $this->uploadDir,
+      $this->configAndLogDir,
+      $this->customFileUploadDir,
+    ] as $dir) {
       if ($dir && is_dir($dir)) {
         CRM_Utils_File::restrictAccess($dir);
       }
@@ -228,7 +229,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
     $userID = $session->get('userID');
     if ($userID) {
       CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1',
-        array(1 => array($userID, 'Integer'))
+        [1 => [$userID, 'Integer']]
       );
     }
 
@@ -315,7 +316,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
     }
     else {
       // Cannot store permissions -- warn if any modules require them
-      $modules_with_perms = array();
+      $modules_with_perms = [];
       foreach ($module_files as $module_file) {
         $perms = $this->userPermissionClass->getModulePermissions($module_file['prefix']);
         if (!empty($perms)) {
@@ -324,7 +325,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
       }
       if (!empty($modules_with_perms)) {
         CRM_Core_Session::setStatus(
-          ts('Some modules define permissions, but the CMS cannot store them: %1', array(1 => implode(', ', $modules_with_perms))),
+          ts('Some modules define permissions, but the CMS cannot store them: %1', [1 => implode(', ', $modules_with_perms)]),
           ts('Permission Error'),
           'error'
         );
@@ -346,7 +347,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
    * Clear db cache.
    */
   public static function clearDBCache() {
-    $queries = array(
+    $queries = [
       'TRUNCATE TABLE civicrm_acl_cache',
       'TRUNCATE TABLE civicrm_acl_contact_cache',
       'TRUNCATE TABLE civicrm_cache',
@@ -355,7 +356,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
       'TRUNCATE TABLE civicrm_group_contact_cache',
       'TRUNCATE TABLE civicrm_menu',
       'UPDATE civicrm_setting SET value = NULL WHERE name="navigation" AND contact_id IS NOT NULL',
-    );
+    ];
 
     foreach ($queries as $query) {
       CRM_Core_DAO::executeQuery($query);
@@ -401,8 +402,8 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
       $query .= " AND CREATE_TIME < DATE_SUB(NOW(), INTERVAL {$timeInterval})";
     }
 
-    $tableDAO = CRM_Core_DAO::executeQuery($query, array(1 => array($dao->database(), 'String')));
-    $tables = array();
+    $tableDAO = CRM_Core_DAO::executeQuery($query, [1 => [$dao->database(), 'String']]);
+    $tables = [];
     while ($tableDAO->fetch()) {
       $tables[] = $tableDAO->tableName;
     }
@@ -463,7 +464,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
    * @return bool
    */
   public static function isEnabledBackOfficeCreditCardPayments() {
-    return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('BackOffice'));
+    return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(['BackOffice']);
   }
 
   /**
@@ -575,7 +576,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
   /**
    * Is the system permitted to flush caches at the moment.
    */
-  static public function isPermitCacheFlushMode() {
+  public static function isPermitCacheFlushMode() {
     return !CRM_Core_Config::singleton()->doNotResetCache;
   }
 
@@ -588,7 +589,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
    * @param bool $enabled
    *   If true then caches can be cleared at this time.
    */
-  static public function setPermitCacheFlushMode($enabled) {
+  public static function setPermitCacheFlushMode($enabled) {
     CRM_Core_Config::singleton()->doNotResetCache = $enabled ? 0 : 1;
   }