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