API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Core / DAO / EntityFile.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/Core/EntityFile.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
a9d0587b 9 * (GenCodeChecksum:b9ac4293489f424584b9983d1304987f)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the EntityFile entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_EntityFile extends CRM_Core_DAO {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_entity_file';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b
TO
31 /**
32 * primary key
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * physical tablename for entity being joined to file, e.g. civicrm_contact
40 *
41 * @var string
42 */
43 public $entity_table;
c3fc2621 44
e501603b
TO
45 /**
46 * FK to entity table specified in entity_table column.
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $entity_id;
c3fc2621 51
e501603b
TO
52 /**
53 * FK to civicrm_file
54 *
e6ca0a57 55 * @var int
e501603b
TO
56 */
57 public $file_id;
c3fc2621 58
e501603b 59 /**
f41f0342 60 * Class constructor.
e501603b 61 */
c3fc2621 62 public function __construct() {
e501603b
TO
63 $this->__table = 'civicrm_entity_file';
64 parent::__construct();
65 }
c3fc2621 66
449c4e6b
CW
67 /**
68 * Returns localized title of this entity.
69 */
70 public static function getEntityTitle() {
71 return ts('Entity Files');
72 }
73
e501603b 74 /**
f41f0342 75 * Returns foreign keys and entity references.
e501603b
TO
76 *
77 * @return array
78 * [CRM_Core_Reference_Interface]
79 */
c3fc2621 80 public static function getReferenceColumns() {
346aaaba 81 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 82 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
83 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'file_id', 'civicrm_file', 'id');
84 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 85 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 86 }
346aaaba 87 return Civi::$statics[__CLASS__]['links'];
e501603b 88 }
c3fc2621 89
e501603b
TO
90 /**
91 * Returns all the column names of this table
92 *
93 * @return array
94 */
c3fc2621 95 public static function &fields() {
346aaaba 96 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
97 Civi::$statics[__CLASS__]['fields'] = [
98 'id' => [
e501603b
TO
99 'name' => 'id',
100 'type' => CRM_Utils_Type::T_INT,
c3fc2621 101 'title' => ts('Entity File ID'),
215b423e 102 'description' => ts('primary key'),
c3fc2621 103 'required' => TRUE,
a36434b9 104 'where' => 'civicrm_entity_file.id',
522a26c9 105 'table_name' => 'civicrm_entity_file',
106 'entity' => 'EntityFile',
107 'bao' => 'CRM_Core_DAO_EntityFile',
6a7e5e5d 108 'localizable' => 0,
a9d0587b 109 'add' => '1.5',
c3fc2621
CW
110 ],
111 'entity_table' => [
e501603b
TO
112 'name' => 'entity_table',
113 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 114 'title' => ts('Entity Table'),
215b423e 115 'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'),
e501603b
TO
116 'maxlength' => 64,
117 'size' => CRM_Utils_Type::BIG,
a36434b9 118 'where' => 'civicrm_entity_file.entity_table',
522a26c9 119 'table_name' => 'civicrm_entity_file',
120 'entity' => 'EntityFile',
121 'bao' => 'CRM_Core_DAO_EntityFile',
6a7e5e5d 122 'localizable' => 0,
a9d0587b 123 'add' => '1.5',
c3fc2621
CW
124 ],
125 'entity_id' => [
e501603b
TO
126 'name' => 'entity_id',
127 'type' => CRM_Utils_Type::T_INT,
c3fc2621 128 'title' => ts('Entity ID'),
215b423e 129 'description' => ts('FK to entity table specified in entity_table column.'),
c3fc2621 130 'required' => TRUE,
a36434b9 131 'where' => 'civicrm_entity_file.entity_id',
522a26c9 132 'table_name' => 'civicrm_entity_file',
133 'entity' => 'EntityFile',
134 'bao' => 'CRM_Core_DAO_EntityFile',
6a7e5e5d 135 'localizable' => 0,
a9d0587b 136 'add' => '1.5',
c3fc2621
CW
137 ],
138 'file_id' => [
e501603b
TO
139 'name' => 'file_id',
140 'type' => CRM_Utils_Type::T_INT,
c3fc2621 141 'title' => ts('File'),
215b423e 142 'description' => ts('FK to civicrm_file'),
c3fc2621 143 'required' => TRUE,
a36434b9 144 'where' => 'civicrm_entity_file.file_id',
522a26c9 145 'table_name' => 'civicrm_entity_file',
146 'entity' => 'EntityFile',
147 'bao' => 'CRM_Core_DAO_EntityFile',
6a7e5e5d 148 'localizable' => 0,
e501603b 149 'FKClassName' => 'CRM_Core_DAO_File',
a9d0587b 150 'add' => '1.5',
c3fc2621
CW
151 ],
152 ];
346aaaba 153 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 154 }
346aaaba 155 return Civi::$statics[__CLASS__]['fields'];
e501603b 156 }
c3fc2621 157
e501603b 158 /**
bd8e0b14 159 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
160 *
161 * @return array
bd8e0b14 162 * Array(string $name => string $uniqueName).
e501603b 163 */
c3fc2621 164 public static function &fieldKeys() {
bd8e0b14
TO
165 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
166 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 167 }
bd8e0b14 168 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 169 }
c3fc2621 170
e501603b
TO
171 /**
172 * Returns the names of this table
173 *
174 * @return string
175 */
c3fc2621 176 public static function getTableName() {
e501603b
TO
177 return self::$_tableName;
178 }
c3fc2621 179
e501603b
TO
180 /**
181 * Returns if this table needs to be logged
182 *
c3fc2621 183 * @return bool
e501603b 184 */
c3fc2621 185 public function getLog() {
e501603b
TO
186 return self::$_log;
187 }
c3fc2621 188
e501603b
TO
189 /**
190 * Returns the list of fields that can be imported
191 *
192 * @param bool $prefix
193 *
194 * @return array
195 */
c3fc2621
CW
196 public static function &import($prefix = FALSE) {
197 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'entity_file', $prefix, []);
60808919 198 return $r;
e501603b 199 }
c3fc2621 200
e501603b
TO
201 /**
202 * Returns the list of fields that can be exported
203 *
204 * @param bool $prefix
205 *
206 * @return array
207 */
c3fc2621
CW
208 public static function &export($prefix = FALSE) {
209 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'entity_file', $prefix, []);
60808919 210 return $r;
e501603b 211 }
c3fc2621 212
e7a6b91a
AS
213 /**
214 * Returns the list of indices
c3fc2621
CW
215 *
216 * @param bool $localize
217 *
218 * @return array
e7a6b91a
AS
219 */
220 public static function indices($localize = TRUE) {
c3fc2621
CW
221 $indices = [
222 'index_entity' => [
e7a6b91a 223 'name' => 'index_entity',
c3fc2621 224 'field' => [
e7a6b91a
AS
225 0 => 'entity_table',
226 1 => 'entity_id',
c3fc2621
CW
227 ],
228 'localizable' => FALSE,
e7a6b91a 229 'sig' => 'civicrm_entity_file::0::entity_table::entity_id',
c3fc2621 230 ],
8506cda6 231 'UI_entity_table_entity_id_file_id' => [
232 'name' => 'UI_entity_table_entity_id_file_id',
c3fc2621 233 'field' => [
e7a6b91a
AS
234 0 => 'entity_table',
235 1 => 'entity_id',
236 2 => 'file_id',
c3fc2621
CW
237 ],
238 'localizable' => FALSE,
8506cda6 239 'unique' => TRUE,
240 'sig' => 'civicrm_entity_file::1::entity_table::entity_id::file_id',
c3fc2621
CW
241 ],
242 ];
e7a6b91a
AS
243 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
244 }
c3fc2621 245
e501603b 246}