Merge pull request #18554 from civicrm/5.30
[civicrm-core.git] / CRM / Dedupe / DAO / Rule.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Dedupe/Rule.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:1c0c64573702774a043ea32c73f05bd8)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Rule entity.
f41f0342 14 */
e501603b 15class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.8';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_dedupe_rule';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = FALSE;
c3fc2621 32
e501603b
TO
33 /**
34 * Unique dedupe rule id
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * The id of the rule group this rule belongs to
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $dedupe_rule_group_id;
c3fc2621 46
e501603b
TO
47 /**
48 * The name of the table this rule is about
49 *
50 * @var string
51 */
52 public $rule_table;
c3fc2621 53
e501603b
TO
54 /**
55 * The name of the field of the table referenced in rule_table
56 *
57 * @var string
58 */
59 public $rule_field;
c3fc2621 60
e501603b
TO
61 /**
62 * The length of the matching substring
63 *
e6ca0a57 64 * @var int
e501603b
TO
65 */
66 public $rule_length;
c3fc2621 67
e501603b
TO
68 /**
69 * The weight of the rule
70 *
71 * @var int
72 */
73 public $rule_weight;
c3fc2621 74
e501603b 75 /**
f41f0342 76 * Class constructor.
e501603b 77 */
c3fc2621 78 public function __construct() {
e501603b
TO
79 $this->__table = 'civicrm_dedupe_rule';
80 parent::__construct();
81 }
c3fc2621 82
449c4e6b
CW
83 /**
84 * Returns localized title of this entity.
7b66c3b5
AH
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
449c4e6b 88 */
7b66c3b5
AH
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Rules') : ts('Rule');
449c4e6b
CW
91 }
92
e501603b 93 /**
f41f0342 94 * Returns foreign keys and entity references.
e501603b
TO
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
c3fc2621 99 public static function getReferenceColumns() {
346aaaba 100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'dedupe_rule_group_id', 'civicrm_dedupe_rule_group', 'id');
346aaaba 103 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 104 }
346aaaba 105 return Civi::$statics[__CLASS__]['links'];
e501603b 106 }
c3fc2621 107
e501603b
TO
108 /**
109 * Returns all the column names of this table
110 *
111 * @return array
112 */
c3fc2621 113 public static function &fields() {
346aaaba 114 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
115 Civi::$statics[__CLASS__]['fields'] = [
116 'id' => [
e501603b
TO
117 'name' => 'id',
118 'type' => CRM_Utils_Type::T_INT,
c3fc2621 119 'title' => ts('Dedupe Rule ID'),
215b423e 120 'description' => ts('Unique dedupe rule id'),
c3fc2621 121 'required' => TRUE,
a36434b9 122 'where' => 'civicrm_dedupe_rule.id',
522a26c9 123 'table_name' => 'civicrm_dedupe_rule',
124 'entity' => 'Rule',
125 'bao' => 'CRM_Dedupe_BAO_Rule',
6a7e5e5d 126 'localizable' => 0,
a9d0587b 127 'add' => '1.8',
c3fc2621
CW
128 ],
129 'dedupe_rule_group_id' => [
e501603b
TO
130 'name' => 'dedupe_rule_group_id',
131 'type' => CRM_Utils_Type::T_INT,
c3fc2621 132 'title' => ts('Dedupe Rule Group'),
215b423e 133 'description' => ts('The id of the rule group this rule belongs to'),
c3fc2621 134 'required' => TRUE,
a36434b9 135 'where' => 'civicrm_dedupe_rule.dedupe_rule_group_id',
522a26c9 136 'table_name' => 'civicrm_dedupe_rule',
137 'entity' => 'Rule',
138 'bao' => 'CRM_Dedupe_BAO_Rule',
6a7e5e5d 139 'localizable' => 0,
e501603b 140 'FKClassName' => 'CRM_Dedupe_DAO_RuleGroup',
a9d0587b 141 'add' => '1.8',
c3fc2621
CW
142 ],
143 'rule_table' => [
e501603b
TO
144 'name' => 'rule_table',
145 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 146 'title' => ts('Rule Table'),
215b423e 147 'description' => ts('The name of the table this rule is about'),
c3fc2621 148 'required' => TRUE,
e501603b
TO
149 'maxlength' => 64,
150 'size' => CRM_Utils_Type::BIG,
a36434b9 151 'where' => 'civicrm_dedupe_rule.rule_table',
522a26c9 152 'table_name' => 'civicrm_dedupe_rule',
153 'entity' => 'Rule',
154 'bao' => 'CRM_Dedupe_BAO_Rule',
6a7e5e5d 155 'localizable' => 0,
a9d0587b 156 'add' => '1.8',
c3fc2621
CW
157 ],
158 'rule_field' => [
e501603b
TO
159 'name' => 'rule_field',
160 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 161 'title' => ts('Rule Field'),
215b423e 162 'description' => ts('The name of the field of the table referenced in rule_table'),
c3fc2621 163 'required' => TRUE,
e501603b
TO
164 'maxlength' => 64,
165 'size' => CRM_Utils_Type::BIG,
a36434b9 166 'where' => 'civicrm_dedupe_rule.rule_field',
522a26c9 167 'table_name' => 'civicrm_dedupe_rule',
168 'entity' => 'Rule',
169 'bao' => 'CRM_Dedupe_BAO_Rule',
6a7e5e5d 170 'localizable' => 0,
a9d0587b 171 'add' => '1.8',
c3fc2621
CW
172 ],
173 'rule_length' => [
e501603b
TO
174 'name' => 'rule_length',
175 'type' => CRM_Utils_Type::T_INT,
c3fc2621 176 'title' => ts('Rule Length'),
215b423e 177 'description' => ts('The length of the matching substring'),
a36434b9 178 'where' => 'civicrm_dedupe_rule.rule_length',
522a26c9 179 'table_name' => 'civicrm_dedupe_rule',
180 'entity' => 'Rule',
181 'bao' => 'CRM_Dedupe_BAO_Rule',
6a7e5e5d 182 'localizable' => 0,
c3fc2621 183 'html' => [
e501603b 184 'type' => 'Text',
c3fc2621 185 ],
a9d0587b 186 'add' => '1.8',
c3fc2621
CW
187 ],
188 'rule_weight' => [
e501603b
TO
189 'name' => 'rule_weight',
190 'type' => CRM_Utils_Type::T_INT,
c3fc2621 191 'title' => ts('Order'),
215b423e 192 'description' => ts('The weight of the rule'),
c3fc2621 193 'required' => TRUE,
a36434b9 194 'where' => 'civicrm_dedupe_rule.rule_weight',
522a26c9 195 'table_name' => 'civicrm_dedupe_rule',
196 'entity' => 'Rule',
197 'bao' => 'CRM_Dedupe_BAO_Rule',
6a7e5e5d 198 'localizable' => 0,
c3fc2621 199 'html' => [
e501603b 200 'type' => 'Text',
c3fc2621 201 ],
a9d0587b 202 'add' => '1.8',
c3fc2621
CW
203 ],
204 ];
346aaaba 205 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 206 }
346aaaba 207 return Civi::$statics[__CLASS__]['fields'];
e501603b 208 }
c3fc2621 209
e501603b 210 /**
bd8e0b14 211 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
212 *
213 * @return array
bd8e0b14 214 * Array(string $name => string $uniqueName).
e501603b 215 */
c3fc2621 216 public static function &fieldKeys() {
bd8e0b14
TO
217 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
218 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 219 }
bd8e0b14 220 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 221 }
c3fc2621 222
e501603b
TO
223 /**
224 * Returns the names of this table
225 *
226 * @return string
227 */
c3fc2621 228 public static function getTableName() {
e501603b
TO
229 return self::$_tableName;
230 }
c3fc2621 231
e501603b
TO
232 /**
233 * Returns if this table needs to be logged
234 *
c3fc2621 235 * @return bool
e501603b 236 */
c3fc2621 237 public function getLog() {
e501603b
TO
238 return self::$_log;
239 }
c3fc2621 240
e501603b
TO
241 /**
242 * Returns the list of fields that can be imported
243 *
244 * @param bool $prefix
245 *
246 * @return array
247 */
c3fc2621
CW
248 public static function &import($prefix = FALSE) {
249 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'dedupe_rule', $prefix, []);
60808919 250 return $r;
e501603b 251 }
c3fc2621 252
e501603b
TO
253 /**
254 * Returns the list of fields that can be exported
255 *
256 * @param bool $prefix
257 *
258 * @return array
259 */
c3fc2621
CW
260 public static function &export($prefix = FALSE) {
261 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'dedupe_rule', $prefix, []);
60808919 262 return $r;
e501603b 263 }
c3fc2621 264
e7a6b91a
AS
265 /**
266 * Returns the list of indices
c3fc2621
CW
267 *
268 * @param bool $localize
269 *
270 * @return array
e7a6b91a
AS
271 */
272 public static function indices($localize = TRUE) {
c3fc2621 273 $indices = [];
e7a6b91a
AS
274 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
275 }
c3fc2621 276
e501603b 277}