Merge pull request #22495 from eileenmcnaughton/fin2
[civicrm-core.git] / CRM / Core / DAO / Managed.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Managed.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ca11b419bcdf2bce26609d9488527023)
10 */
11
12 /**
13 * Database access object for the Managed entity.
14 */
15 class CRM_Core_DAO_Managed extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.2';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_managed';
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 * Surrogate Key
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Name of the module which declared this object
42 *
43 * @var string
44 */
45 public $module;
46
47 /**
48 * Symbolic name used by the module to identify the object
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * API entity type
56 *
57 * @var string
58 */
59 public $entity_type;
60
61 /**
62 * Foreign key to the referenced item.
63 *
64 * @var int
65 */
66 public $entity_id;
67
68 /**
69 * Policy on when to cleanup entity (always, never, unused)
70 *
71 * @var string
72 */
73 public $cleanup;
74
75 /**
76 * When the managed entity was changed from its original settings.
77 *
78 * @var timestamp
79 */
80 public $entity_modified_date;
81
82 /**
83 * Class constructor.
84 */
85 public function __construct() {
86 $this->__table = 'civicrm_managed';
87 parent::__construct();
88 }
89
90 /**
91 * Returns localized title of this entity.
92 *
93 * @param bool $plural
94 * Whether to return the plural version of the title.
95 */
96 public static function getEntityTitle($plural = FALSE) {
97 return $plural ? ts('Manageds') : ts('Managed');
98 }
99
100 /**
101 * Returns all the column names of this table
102 *
103 * @return array
104 */
105 public static function &fields() {
106 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
107 Civi::$statics[__CLASS__]['fields'] = [
108 'id' => [
109 'name' => 'id',
110 'type' => CRM_Utils_Type::T_INT,
111 'title' => ts('Managed ID'),
112 'description' => ts('Surrogate Key'),
113 'required' => TRUE,
114 'where' => 'civicrm_managed.id',
115 'table_name' => 'civicrm_managed',
116 'entity' => 'Managed',
117 'bao' => 'CRM_Core_BAO_Managed',
118 'localizable' => 0,
119 'html' => [
120 'type' => 'Number',
121 ],
122 'readonly' => TRUE,
123 'add' => '4.2',
124 ],
125 'module' => [
126 'name' => 'module',
127 'type' => CRM_Utils_Type::T_STRING,
128 'title' => ts('Module'),
129 'description' => ts('Name of the module which declared this object'),
130 'required' => TRUE,
131 'maxlength' => 127,
132 'size' => CRM_Utils_Type::HUGE,
133 'where' => 'civicrm_managed.module',
134 'table_name' => 'civicrm_managed',
135 'entity' => 'Managed',
136 'bao' => 'CRM_Core_BAO_Managed',
137 'localizable' => 0,
138 'add' => '4.2',
139 ],
140 'name' => [
141 'name' => 'name',
142 'type' => CRM_Utils_Type::T_STRING,
143 'title' => ts('Name'),
144 'description' => ts('Symbolic name used by the module to identify the object'),
145 'maxlength' => 127,
146 'size' => CRM_Utils_Type::HUGE,
147 'where' => 'civicrm_managed.name',
148 'table_name' => 'civicrm_managed',
149 'entity' => 'Managed',
150 'bao' => 'CRM_Core_BAO_Managed',
151 'localizable' => 0,
152 'add' => '4.2',
153 ],
154 'entity_type' => [
155 'name' => 'entity_type',
156 'type' => CRM_Utils_Type::T_STRING,
157 'title' => ts('Entity Type'),
158 'description' => ts('API entity type'),
159 'required' => TRUE,
160 'maxlength' => 64,
161 'size' => CRM_Utils_Type::BIG,
162 'where' => 'civicrm_managed.entity_type',
163 'table_name' => 'civicrm_managed',
164 'entity' => 'Managed',
165 'bao' => 'CRM_Core_BAO_Managed',
166 'localizable' => 0,
167 'add' => '4.2',
168 ],
169 'entity_id' => [
170 'name' => 'entity_id',
171 'type' => CRM_Utils_Type::T_INT,
172 'title' => ts('Entity ID'),
173 'description' => ts('Foreign key to the referenced item.'),
174 'required' => TRUE,
175 'where' => 'civicrm_managed.entity_id',
176 'table_name' => 'civicrm_managed',
177 'entity' => 'Managed',
178 'bao' => 'CRM_Core_BAO_Managed',
179 'localizable' => 0,
180 'add' => '4.2',
181 ],
182 'cleanup' => [
183 'name' => 'cleanup',
184 'type' => CRM_Utils_Type::T_STRING,
185 'title' => ts('Cleanup Setting'),
186 'description' => ts('Policy on when to cleanup entity (always, never, unused)'),
187 'maxlength' => 32,
188 'size' => CRM_Utils_Type::MEDIUM,
189 'where' => 'civicrm_managed.cleanup',
190 'table_name' => 'civicrm_managed',
191 'entity' => 'Managed',
192 'bao' => 'CRM_Core_BAO_Managed',
193 'localizable' => 0,
194 'html' => [
195 'type' => 'Select',
196 ],
197 'pseudoconstant' => [
198 'callback' => 'CRM_Core_ManagedEntities::getCleanupOptions',
199 ],
200 'add' => '4.5',
201 ],
202 'entity_modified_date' => [
203 'name' => 'entity_modified_date',
204 'type' => CRM_Utils_Type::T_TIMESTAMP,
205 'title' => ts('Entity Modified Date'),
206 'description' => ts('When the managed entity was changed from its original settings.'),
207 'required' => FALSE,
208 'where' => 'civicrm_managed.entity_modified_date',
209 'default' => NULL,
210 'table_name' => 'civicrm_managed',
211 'entity' => 'Managed',
212 'bao' => 'CRM_Core_BAO_Managed',
213 'localizable' => 0,
214 'add' => '5.45',
215 ],
216 ];
217 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
218 }
219 return Civi::$statics[__CLASS__]['fields'];
220 }
221
222 /**
223 * Return a mapping from field-name to the corresponding key (as used in fields()).
224 *
225 * @return array
226 * Array(string $name => string $uniqueName).
227 */
228 public static function &fieldKeys() {
229 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
230 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
231 }
232 return Civi::$statics[__CLASS__]['fieldKeys'];
233 }
234
235 /**
236 * Returns the names of this table
237 *
238 * @return string
239 */
240 public static function getTableName() {
241 return self::$_tableName;
242 }
243
244 /**
245 * Returns if this table needs to be logged
246 *
247 * @return bool
248 */
249 public function getLog() {
250 return self::$_log;
251 }
252
253 /**
254 * Returns the list of fields that can be imported
255 *
256 * @param bool $prefix
257 *
258 * @return array
259 */
260 public static function &import($prefix = FALSE) {
261 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'managed', $prefix, []);
262 return $r;
263 }
264
265 /**
266 * Returns the list of fields that can be exported
267 *
268 * @param bool $prefix
269 *
270 * @return array
271 */
272 public static function &export($prefix = FALSE) {
273 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'managed', $prefix, []);
274 return $r;
275 }
276
277 /**
278 * Returns the list of indices
279 *
280 * @param bool $localize
281 *
282 * @return array
283 */
284 public static function indices($localize = TRUE) {
285 $indices = [
286 'UI_managed_module_name' => [
287 'name' => 'UI_managed_module_name',
288 'field' => [
289 0 => 'module',
290 1 => 'name',
291 ],
292 'localizable' => FALSE,
293 'sig' => 'civicrm_managed::0::module::name',
294 ],
295 'UI_managed_entity' => [
296 'name' => 'UI_managed_entity',
297 'field' => [
298 0 => 'entity_type',
299 1 => 'entity_id',
300 ],
301 'localizable' => FALSE,
302 'sig' => 'civicrm_managed::0::entity_type::entity_id',
303 ],
304 ];
305 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
306 }
307
308 }