30e60b048f1743212831d0021fb6a73b410fb1d4
[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:3c6ae22144ccb74c38f5a043e5edf7db)
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 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_managed';
80 parent::__construct();
81 }
82
83 /**
84 * Returns localized title of this entity.
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
88 */
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Manageds') : ts('Managed');
91 }
92
93 /**
94 * Returns all the column names of this table
95 *
96 * @return array
97 */
98 public static function &fields() {
99 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
100 Civi::$statics[__CLASS__]['fields'] = [
101 'id' => [
102 'name' => 'id',
103 'type' => CRM_Utils_Type::T_INT,
104 'title' => ts('Managed ID'),
105 'description' => ts('Surrogate Key'),
106 'required' => TRUE,
107 'where' => 'civicrm_managed.id',
108 'table_name' => 'civicrm_managed',
109 'entity' => 'Managed',
110 'bao' => 'CRM_Core_DAO_Managed',
111 'localizable' => 0,
112 'html' => [
113 'type' => 'Number',
114 ],
115 'add' => '4.2',
116 ],
117 'module' => [
118 'name' => 'module',
119 'type' => CRM_Utils_Type::T_STRING,
120 'title' => ts('Module'),
121 'description' => ts('Name of the module which declared this object'),
122 'required' => TRUE,
123 'maxlength' => 127,
124 'size' => CRM_Utils_Type::HUGE,
125 'where' => 'civicrm_managed.module',
126 'table_name' => 'civicrm_managed',
127 'entity' => 'Managed',
128 'bao' => 'CRM_Core_DAO_Managed',
129 'localizable' => 0,
130 'add' => '4.2',
131 ],
132 'name' => [
133 'name' => 'name',
134 'type' => CRM_Utils_Type::T_STRING,
135 'title' => ts('Name'),
136 'description' => ts('Symbolic name used by the module to identify the object'),
137 'maxlength' => 127,
138 'size' => CRM_Utils_Type::HUGE,
139 'where' => 'civicrm_managed.name',
140 'table_name' => 'civicrm_managed',
141 'entity' => 'Managed',
142 'bao' => 'CRM_Core_DAO_Managed',
143 'localizable' => 0,
144 'add' => '4.2',
145 ],
146 'entity_type' => [
147 'name' => 'entity_type',
148 'type' => CRM_Utils_Type::T_STRING,
149 'title' => ts('Entity Type'),
150 'description' => ts('API entity type'),
151 'required' => TRUE,
152 'maxlength' => 64,
153 'size' => CRM_Utils_Type::BIG,
154 'where' => 'civicrm_managed.entity_type',
155 'table_name' => 'civicrm_managed',
156 'entity' => 'Managed',
157 'bao' => 'CRM_Core_DAO_Managed',
158 'localizable' => 0,
159 'add' => '4.2',
160 ],
161 'entity_id' => [
162 'name' => 'entity_id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Entity ID'),
165 'description' => ts('Foreign key to the referenced item.'),
166 'required' => TRUE,
167 'where' => 'civicrm_managed.entity_id',
168 'table_name' => 'civicrm_managed',
169 'entity' => 'Managed',
170 'bao' => 'CRM_Core_DAO_Managed',
171 'localizable' => 0,
172 'add' => '4.2',
173 ],
174 'cleanup' => [
175 'name' => 'cleanup',
176 'type' => CRM_Utils_Type::T_STRING,
177 'title' => ts('Cleanup Setting'),
178 'description' => ts('Policy on when to cleanup entity (always, never, unused)'),
179 'maxlength' => 32,
180 'size' => CRM_Utils_Type::MEDIUM,
181 'where' => 'civicrm_managed.cleanup',
182 'table_name' => 'civicrm_managed',
183 'entity' => 'Managed',
184 'bao' => 'CRM_Core_DAO_Managed',
185 'localizable' => 0,
186 'html' => [
187 'type' => 'Select',
188 ],
189 'pseudoconstant' => [
190 'callback' => 'CRM_Core_ManagedEntities::getCleanupOptions',
191 ],
192 'add' => '4.5',
193 ],
194 ];
195 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
196 }
197 return Civi::$statics[__CLASS__]['fields'];
198 }
199
200 /**
201 * Return a mapping from field-name to the corresponding key (as used in fields()).
202 *
203 * @return array
204 * Array(string $name => string $uniqueName).
205 */
206 public static function &fieldKeys() {
207 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
208 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
209 }
210 return Civi::$statics[__CLASS__]['fieldKeys'];
211 }
212
213 /**
214 * Returns the names of this table
215 *
216 * @return string
217 */
218 public static function getTableName() {
219 return self::$_tableName;
220 }
221
222 /**
223 * Returns if this table needs to be logged
224 *
225 * @return bool
226 */
227 public function getLog() {
228 return self::$_log;
229 }
230
231 /**
232 * Returns the list of fields that can be imported
233 *
234 * @param bool $prefix
235 *
236 * @return array
237 */
238 public static function &import($prefix = FALSE) {
239 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'managed', $prefix, []);
240 return $r;
241 }
242
243 /**
244 * Returns the list of fields that can be exported
245 *
246 * @param bool $prefix
247 *
248 * @return array
249 */
250 public static function &export($prefix = FALSE) {
251 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'managed', $prefix, []);
252 return $r;
253 }
254
255 /**
256 * Returns the list of indices
257 *
258 * @param bool $localize
259 *
260 * @return array
261 */
262 public static function indices($localize = TRUE) {
263 $indices = [
264 'UI_managed_module_name' => [
265 'name' => 'UI_managed_module_name',
266 'field' => [
267 0 => 'module',
268 1 => 'name',
269 ],
270 'localizable' => FALSE,
271 'sig' => 'civicrm_managed::0::module::name',
272 ],
273 'UI_managed_entity' => [
274 'name' => 'UI_managed_entity',
275 'field' => [
276 0 => 'entity_type',
277 1 => 'entity_id',
278 ],
279 'localizable' => FALSE,
280 'sig' => 'civicrm_managed::0::entity_type::entity_id',
281 ],
282 ];
283 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
284 }
285
286 }