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