Merge pull request #9668 from colemanw/CRM-19864
[civicrm-core.git] / CRM / Batch / DAO / Batch.php
index 6f162d9c18b966be3a8b6cb90187ef7e58a72142..14ed8afb134ecb719a5b5385e9d458c95d5cd369 100644 (file)
@@ -3,7 +3,7 @@
 +--------------------------------------------------------------------+
 | CiviCRM version 4.7                                                |
 +--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2016                                |
+| Copyright CiviCRM LLC (c) 2004-2017                                |
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 */
 /**
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  *
  * Generated from xml/schema/CRM/Batch/Batch.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:c2030f71901c97e7914636c6c817beb9)
+ * (GenCodeChecksum:d02020e92b997906c5591971b4c4b988)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
+/**
+ * CRM_Batch_DAO_Batch constructor.
+ */
 class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
   /**
-   * static instance to hold the table name
+   * Static instance to hold the table name.
    *
    * @var string
    */
   static $_tableName = 'civicrm_batch';
   /**
-   * 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
+   * Should CiviCRM log any modifications to this table in the civicrm_log table.
    *
    * @var boolean
    */
@@ -182,28 +152,27 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
    */
   public $data;
   /**
-   * class constructor
-   *
-   * @return civicrm_batch
+   * Class constructor.
    */
   function __construct() {
     $this->__table = 'civicrm_batch';
     parent::__construct();
   }
   /**
-   * Returns foreign keys and entity references
+   * Returns foreign keys and entity references.
    *
    * @return array
    *   [CRM_Core_Reference_Interface]
    */
   static function getReferenceColumns() {
-    if (!self::$_links) {
-      self::$_links = static ::createReferenceColumns(__CLASS__);
-      self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
-      self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'modified_id', 'civicrm_contact', 'id');
-      self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'saved_search_id', 'civicrm_saved_search', 'id');
+    if (!isset(Civi::$statics[__CLASS__]['links'])) {
+      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
+      Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'modified_id', 'civicrm_contact', 'id');
+      Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'saved_search_id', 'civicrm_saved_search', 'id');
+      CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
-    return self::$_links;
+    return Civi::$statics[__CLASS__]['links'];
   }
   /**
    * Returns all the column names of this table
@@ -211,14 +180,17 @@ class CRM_Batch_DAO_Batch 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,
           'title' => ts('Batch ID') ,
           'description' => 'Unique Address ID',
           'required' => true,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
         ) ,
         'name' => array(
           'name' => 'name',
@@ -227,6 +199,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'description' => 'Variable name/programmatic handle for this batch.',
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Text',
           ) ,
@@ -238,6 +213,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'description' => 'Friendly Name.',
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Text',
           ) ,
@@ -249,6 +227,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'description' => 'Description of this batch set.',
           'rows' => 4,
           'cols' => 80,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'TextArea',
           ) ,
@@ -258,6 +239,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Created By') ,
           'description' => 'FK to Contact ID',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'FKClassName' => 'CRM_Contact_DAO_Contact',
         ) ,
         'created_date' => array(
@@ -265,6 +249,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Batch Created Date') ,
           'description' => 'When was this item created',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Select Date',
           ) ,
@@ -274,6 +261,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Modified By') ,
           'description' => 'FK to Contact ID',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'FKClassName' => 'CRM_Contact_DAO_Contact',
         ) ,
         'modified_date' => array(
@@ -281,12 +271,18 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Batch Modified Date') ,
           'description' => 'When was this item created',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
         ) ,
         'saved_search_id' => array(
           'name' => 'saved_search_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Smart Group') ,
           'description' => 'FK to Saved Search ID',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
           'html' => array(
             'type' => 'EntityRef',
@@ -298,6 +294,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'title' => ts('Batch Status') ,
           'description' => 'fk to Batch Status options in civicrm_option_values',
           'required' => true,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Select',
           ) ,
@@ -311,6 +310,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Type') ,
           'description' => 'fk to Batch Type options in civicrm_option_values',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Select',
           ) ,
@@ -324,6 +326,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Mode') ,
           'description' => 'fk to Batch mode options in civicrm_option_values',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Select',
           ) ,
@@ -341,6 +346,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
             20,
             2
           ) ,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Text',
           ) ,
@@ -350,6 +358,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Number of Items') ,
           'description' => 'Number of items in a batch.',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Text',
           ) ,
@@ -359,6 +370,9 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Payment Method') ,
           'description' => 'fk to Payment Instrument options in civicrm_option_values',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
           'html' => array(
             'type' => 'Select',
           ) ,
@@ -371,46 +385,35 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'name' => 'exported_date',
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Batch Exported Date') ,
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
         ) ,
         'data' => array(
           'name' => 'data',
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Batch Data') ,
           'description' => 'cache entered data',
+          'table_name' => 'civicrm_batch',
+          'entity' => 'Batch',
+          'bao' => 'CRM_Batch_BAO_Batch',
         ) ,
       );
+      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',
-        'title' => 'title',
-        'description' => 'description',
-        'created_id' => 'created_id',
-        'created_date' => 'created_date',
-        'modified_id' => 'modified_id',
-        'modified_date' => 'modified_date',
-        'saved_search_id' => 'saved_search_id',
-        'status_id' => 'status_id',
-        'type_id' => 'type_id',
-        'mode_id' => 'mode_id',
-        'total' => 'total',
-        'item_count' => 'item_count',
-        'payment_instrument_id' => 'payment_instrument_id',
-        'exported_date' => 'exported_date',
-        'data' => 'data',
-      );
+    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
@@ -436,20 +439,8 @@ class CRM_Batch_DAO_Batch 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['batch'] = & $fields[$name];
-          } else {
-            self::$_import[$name] = & $fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
+    $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'batch', $prefix, array());
+    return $r;
   }
   /**
    * Returns the list of fields that can be exported
@@ -459,19 +450,7 @@ class CRM_Batch_DAO_Batch 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['batch'] = & $fields[$name];
-          } else {
-            self::$_export[$name] = & $fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
+    $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'batch', $prefix, array());
+    return $r;
   }
 }