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