Merge pull request #14059 from Stoob/patch-2
[civicrm-core.git] / CRM / Core / DAO / EntityTag.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/EntityTag.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:721b045d10e22535a86c5e927e489477)
10 */
11
12 /**
13 * Database access object for the EntityTag entity.
14 */
15 class CRM_Core_DAO_EntityTag extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_entity_tag';
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 = TRUE;
30
31 /**
32 * primary key
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * physical tablename for entity being joined to file, e.g. civicrm_contact
40 *
41 * @var string
42 */
43 public $entity_table;
44
45 /**
46 * FK to entity table specified in entity_table column.
47 *
48 * @var int unsigned
49 */
50 public $entity_id;
51
52 /**
53 * FK to civicrm_tag
54 *
55 * @var int unsigned
56 */
57 public $tag_id;
58
59 /**
60 * Class constructor.
61 */
62 public function __construct() {
63 $this->__table = 'civicrm_entity_tag';
64 parent::__construct();
65 }
66
67 /**
68 * Returns foreign keys and entity references.
69 *
70 * @return array
71 * [CRM_Core_Reference_Interface]
72 */
73 public static function getReferenceColumns() {
74 if (!isset(Civi::$statics[__CLASS__]['links'])) {
75 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
76 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'tag_id', 'civicrm_tag', 'id');
77 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
78 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
79 }
80 return Civi::$statics[__CLASS__]['links'];
81 }
82
83 /**
84 * Returns all the column names of this table
85 *
86 * @return array
87 */
88 public static function &fields() {
89 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
90 Civi::$statics[__CLASS__]['fields'] = [
91 'id' => [
92 'name' => 'id',
93 'type' => CRM_Utils_Type::T_INT,
94 'title' => ts('Entity Tag ID'),
95 'description' => ts('primary key'),
96 'required' => TRUE,
97 'where' => 'civicrm_entity_tag.id',
98 'table_name' => 'civicrm_entity_tag',
99 'entity' => 'EntityTag',
100 'bao' => 'CRM_Core_BAO_EntityTag',
101 'localizable' => 0,
102 ],
103 'entity_table' => [
104 'name' => 'entity_table',
105 'type' => CRM_Utils_Type::T_STRING,
106 'title' => ts('Entity Table'),
107 'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'),
108 'maxlength' => 64,
109 'size' => CRM_Utils_Type::BIG,
110 'where' => 'civicrm_entity_tag.entity_table',
111 'table_name' => 'civicrm_entity_tag',
112 'entity' => 'EntityTag',
113 'bao' => 'CRM_Core_BAO_EntityTag',
114 'localizable' => 0,
115 'pseudoconstant' => [
116 'optionGroupName' => 'tag_used_for',
117 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
118 ]
119 ],
120 'entity_id' => [
121 'name' => 'entity_id',
122 'type' => CRM_Utils_Type::T_INT,
123 'title' => ts('Entity ID'),
124 'description' => ts('FK to entity table specified in entity_table column.'),
125 'required' => TRUE,
126 'where' => 'civicrm_entity_tag.entity_id',
127 'table_name' => 'civicrm_entity_tag',
128 'entity' => 'EntityTag',
129 'bao' => 'CRM_Core_BAO_EntityTag',
130 'localizable' => 0,
131 ],
132 'tag_id' => [
133 'name' => 'tag_id',
134 'type' => CRM_Utils_Type::T_INT,
135 'title' => ts('Tag'),
136 'description' => ts('FK to civicrm_tag'),
137 'required' => TRUE,
138 'where' => 'civicrm_entity_tag.tag_id',
139 'table_name' => 'civicrm_entity_tag',
140 'entity' => 'EntityTag',
141 'bao' => 'CRM_Core_BAO_EntityTag',
142 'localizable' => 0,
143 'FKClassName' => 'CRM_Core_DAO_Tag',
144 'html' => [
145 'type' => 'Select',
146 ],
147 'pseudoconstant' => [
148 'table' => 'civicrm_tag',
149 'keyColumn' => 'id',
150 'labelColumn' => 'name',
151 ]
152 ],
153 ];
154 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
155 }
156 return Civi::$statics[__CLASS__]['fields'];
157 }
158
159 /**
160 * Return a mapping from field-name to the corresponding key (as used in fields()).
161 *
162 * @return array
163 * Array(string $name => string $uniqueName).
164 */
165 public static function &fieldKeys() {
166 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
167 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
168 }
169 return Civi::$statics[__CLASS__]['fieldKeys'];
170 }
171
172 /**
173 * Returns the names of this table
174 *
175 * @return string
176 */
177 public static function getTableName() {
178 return self::$_tableName;
179 }
180
181 /**
182 * Returns if this table needs to be logged
183 *
184 * @return bool
185 */
186 public function getLog() {
187 return self::$_log;
188 }
189
190 /**
191 * Returns the list of fields that can be imported
192 *
193 * @param bool $prefix
194 *
195 * @return array
196 */
197 public static function &import($prefix = FALSE) {
198 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_tag', $prefix, []);
199 return $r;
200 }
201
202 /**
203 * Returns the list of fields that can be exported
204 *
205 * @param bool $prefix
206 *
207 * @return array
208 */
209 public static function &export($prefix = FALSE) {
210 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_tag', $prefix, []);
211 return $r;
212 }
213
214 /**
215 * Returns the list of indices
216 *
217 * @param bool $localize
218 *
219 * @return array
220 */
221 public static function indices($localize = TRUE) {
222 $indices = [
223 'UI_entity_id_entity_table_tag_id' => [
224 'name' => 'UI_entity_id_entity_table_tag_id',
225 'field' => [
226 0 => 'entity_id',
227 1 => 'entity_table',
228 2 => 'tag_id',
229 ],
230 'localizable' => FALSE,
231 'unique' => TRUE,
232 'sig' => 'civicrm_entity_tag::1::entity_id::entity_table::tag_id',
233 ],
234 ];
235 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
236 }
237
238 }