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