Add pseudoconstant to StatusPreference
authorColeman Watts <coleman@civicrm.org>
Tue, 17 Nov 2015 19:53:36 +0000 (14:53 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 17 Nov 2015 19:53:36 +0000 (14:53 -0500)
Fix for failing StatusPreferenceTest - pseudoconstant is needed by api to validate input.

CRM/Utils/Check.php
api/v3/System.php
xml/schema/Core/StatusPreference.xml

index a7db9408ad0ee80a4c0a1346ddd6955f5d7b2855..4aeba74f6fa7d3657bd57589479c63b2d17278dd 100644 (file)
@@ -38,7 +38,7 @@ class CRM_Utils_Check {
    * @var array
    * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
    */
-  public static $severityMap = array(
+  protected static $severityList = array(
     \Psr\Log\LogLevel::DEBUG,
     \Psr\Log\LogLevel::INFO,
     \Psr\Log\LogLevel::NOTICE,
@@ -69,6 +69,13 @@ class CRM_Utils_Check {
     return self::$_singleton;
   }
 
+  /**
+   * @return array
+   */
+  public static function getSeverityList() {
+    return self::$severityList;
+  }
+
   /**
    * Execute "checkAll".
    *
@@ -151,7 +158,7 @@ class CRM_Utils_Check {
       $severity = strtolower($severity);
     }
 
-    return ($reverse) ? self::$severityMap[$severity] : array_search($severity, self::$severityMap);
+    return ($reverse) ? self::$severityList[$severity] : array_search($severity, self::$severityList);
   }
 
   /**
index 0a2f0a44a809f8aa7a7c778dde6ecb5310dbd159..df173f47e9c56997e3e097a801c34b14f18b2aea 100644 (file)
@@ -112,13 +112,13 @@ function _civicrm_api3_system_check_spec(&$spec) {
     'title' => 'Severity',
     'description' => 'Psr\Log\LogLevel string',
     'type' => CRM_Utils_Type::T_STRING,
-    'options' => array_combine(CRM_Utils_Check::$severityMap, CRM_Utils_Check::$severityMap),
+    'options' => array_combine(CRM_Utils_Check::getSeverityList(), CRM_Utils_Check::getSeverityList()),
   );
   $spec['severity_id'] = array(
     'title' => 'Severity ID',
     'description' => 'Integer representation of Psr\Log\LogLevel',
     'type' => CRM_Utils_Type::T_INT,
-    'options' => CRM_Utils_Check::$severityMap,
+    'options' => CRM_Utils_Check::getSeverityList(),
   );
   $spec['is_visible'] = array(
     'title' => 'is visible',
index 7f670d3cb35e58d9ad4ae776728a3f4be10d438e..7e924e641a3047797348cb37d6f001005c062651 100644 (file)
@@ -69,6 +69,9 @@
     <comment>Hush messages up to and including this severity.</comment>
     <default>1</default>
     <add>4.7</add>
+    <pseudoconstant>
+      <callback>CRM_Utils_Check::getSeverityList</callback>
+    </pseudoconstant>
   </field>
   <field>
     <name>prefs</name>