CRM-17663 - Configurable cache time per dashlet & auto-refresh
[civicrm-core.git] / CRM / Core / DAO / Mapping.php
index b71a3ac604ecec97edf2d807ed9ef33e09f98fa3..9d7d795616daae0584f68acc52167f69fc90c13d 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Core/Mapping.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:e2cbe03713267fb3e323225059ee8257)
+ * (GenCodeChecksum:4e293e6d117828f1e2000de5a4a0d0c0)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -41,38 +41,6 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
    * @var string
    */
   static $_tableName = 'civicrm_mapping';
-  /**
-   * static instance to hold the field values
-   *
-   * @var array
-   */
-  static $_fields = null;
-  /**
-   * static instance to hold the keys used in $_fields for each field.
-   *
-   * @var array
-   */
-  static $_fieldKeys = null;
-  /**
-   * static instance to hold the FK relationships
-   *
-   * @var string
-   */
-  static $_links = null;
-  /**
-   * static instance to hold the values that can
-   * be imported
-   *
-   * @var array
-   */
-  static $_import = null;
-  /**
-   * static instance to hold the values that can
-   * be exported
-   *
-   * @var array
-   */
-  static $_export = null;
   /**
    * static value to see if we should log any modifications to
    * this table in the civicrm_log table
@@ -119,8 +87,8 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
    * @return array
    */
   static function &fields() {
-    if (!(self::$_fields)) {
-      self::$_fields = array(
+    if (!isset(Civi::$statics[__CLASS__]['fields'])) {
+      Civi::$statics[__CLASS__]['fields'] = array(
         'id' => array(
           'name' => 'id',
           'type' => CRM_Utils_Type::T_INT,
@@ -158,25 +126,21 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
           )
         ) ,
       );
+      CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
     }
-    return self::$_fields;
+    return Civi::$statics[__CLASS__]['fields'];
   }
   /**
-   * Returns an array containing, for each field, the arary key used for that
-   * field in self::$_fields.
+   * Return a mapping from field-name to the corresponding key (as used in fields()).
    *
    * @return array
+   *   Array(string $name => string $uniqueName).
    */
   static function &fieldKeys() {
-    if (!(self::$_fieldKeys)) {
-      self::$_fieldKeys = array(
-        'id' => 'id',
-        'name' => 'name',
-        'description' => 'description',
-        'mapping_type_id' => 'mapping_type_id',
-      );
+    if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
+      Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
     }
-    return self::$_fieldKeys;
+    return Civi::$statics[__CLASS__]['fieldKeys'];
   }
   /**
    * Returns the names of this table
@@ -202,20 +166,8 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
    * @return array
    */
   static function &import($prefix = false) {
-    if (!(self::$_import)) {
-      self::$_import = array();
-      $fields = self::fields();
-      foreach($fields as $name => $field) {
-        if (CRM_Utils_Array::value('import', $field)) {
-          if ($prefix) {
-            self::$_import['mapping'] = & $fields[$name];
-          } else {
-            self::$_import[$name] = & $fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
+    $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mapping', $prefix, array());
+    return $r;
   }
   /**
    * Returns the list of fields that can be exported
@@ -225,19 +177,7 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
    * @return array
    */
   static function &export($prefix = false) {
-    if (!(self::$_export)) {
-      self::$_export = array();
-      $fields = self::fields();
-      foreach($fields as $name => $field) {
-        if (CRM_Utils_Array::value('export', $field)) {
-          if ($prefix) {
-            self::$_export['mapping'] = & $fields[$name];
-          } else {
-            self::$_export[$name] = & $fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
+    $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mapping', $prefix, array());
+    return $r;
   }
 }