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