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