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