Merge pull request #18231 from civicrm/5.29
[civicrm-core.git] / CRM / Core / DAO / Extension.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Extension.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:08d2151b75e68f334bd88475b58fab7b)
10 */
11
12 /**
13 * Database access object for the Extension entity.
14 */
15 class CRM_Core_DAO_Extension 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_extension';
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 * Local Extension ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * @var string
42 */
43 public $type;
44
45 /**
46 * Fully qualified extension name
47 *
48 * @var string
49 */
50 public $full_name;
51
52 /**
53 * Short name
54 *
55 * @var string
56 */
57 public $name;
58
59 /**
60 * Short, printable name
61 *
62 * @var string
63 */
64 public $label;
65
66 /**
67 * Primary PHP file
68 *
69 * @var string
70 */
71 public $file;
72
73 /**
74 * Revision code of the database schema; the format is module-defined
75 *
76 * @var string
77 */
78 public $schema_version;
79
80 /**
81 * Is this extension active?
82 *
83 * @var bool
84 */
85 public $is_active;
86
87 /**
88 * Class constructor.
89 */
90 public function __construct() {
91 $this->__table = 'civicrm_extension';
92 parent::__construct();
93 }
94
95 /**
96 * Returns localized title of this entity.
97 */
98 public static function getEntityTitle() {
99 return ts('Extensions');
100 }
101
102 /**
103 * Returns all the column names of this table
104 *
105 * @return array
106 */
107 public static function &fields() {
108 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
109 Civi::$statics[__CLASS__]['fields'] = [
110 'id' => [
111 'name' => 'id',
112 'type' => CRM_Utils_Type::T_INT,
113 'title' => ts('Extension ID'),
114 'description' => ts('Local Extension ID'),
115 'required' => TRUE,
116 'where' => 'civicrm_extension.id',
117 'table_name' => 'civicrm_extension',
118 'entity' => 'Extension',
119 'bao' => 'CRM_Core_BAO_Extension',
120 'localizable' => 0,
121 'add' => '4.2',
122 ],
123 'type' => [
124 'name' => 'type',
125 'type' => CRM_Utils_Type::T_STRING,
126 'title' => ts('Type'),
127 'required' => TRUE,
128 'maxlength' => 8,
129 'size' => CRM_Utils_Type::EIGHT,
130 'where' => 'civicrm_extension.type',
131 'table_name' => 'civicrm_extension',
132 'entity' => 'Extension',
133 'bao' => 'CRM_Core_BAO_Extension',
134 'localizable' => 0,
135 'html' => [
136 'type' => 'Select',
137 ],
138 'pseudoconstant' => [
139 'callback' => 'CRM_Core_SelectValues::getExtensionTypes',
140 ],
141 'add' => '4.2',
142 ],
143 'full_name' => [
144 'name' => 'full_name',
145 'type' => CRM_Utils_Type::T_STRING,
146 'title' => ts('Key'),
147 'description' => ts('Fully qualified extension name'),
148 'required' => TRUE,
149 'maxlength' => 255,
150 'size' => CRM_Utils_Type::HUGE,
151 'where' => 'civicrm_extension.full_name',
152 'table_name' => 'civicrm_extension',
153 'entity' => 'Extension',
154 'bao' => 'CRM_Core_BAO_Extension',
155 'localizable' => 0,
156 'add' => '4.2',
157 ],
158 'name' => [
159 'name' => 'name',
160 'type' => CRM_Utils_Type::T_STRING,
161 'title' => ts('Name'),
162 'description' => ts('Short name'),
163 'maxlength' => 255,
164 'size' => CRM_Utils_Type::HUGE,
165 'import' => TRUE,
166 'where' => 'civicrm_extension.name',
167 'export' => TRUE,
168 'table_name' => 'civicrm_extension',
169 'entity' => 'Extension',
170 'bao' => 'CRM_Core_BAO_Extension',
171 'localizable' => 0,
172 'add' => '4.2',
173 ],
174 'label' => [
175 'name' => 'label',
176 'type' => CRM_Utils_Type::T_STRING,
177 'title' => ts('Label'),
178 'description' => ts('Short, printable name'),
179 'maxlength' => 255,
180 'size' => CRM_Utils_Type::HUGE,
181 'import' => TRUE,
182 'where' => 'civicrm_extension.label',
183 'export' => TRUE,
184 'table_name' => 'civicrm_extension',
185 'entity' => 'Extension',
186 'bao' => 'CRM_Core_BAO_Extension',
187 'localizable' => 0,
188 'add' => '4.2',
189 ],
190 'file' => [
191 'name' => 'file',
192 'type' => CRM_Utils_Type::T_STRING,
193 'title' => ts('File'),
194 'description' => ts('Primary PHP file'),
195 'maxlength' => 255,
196 'size' => CRM_Utils_Type::HUGE,
197 'import' => TRUE,
198 'where' => 'civicrm_extension.file',
199 'export' => TRUE,
200 'table_name' => 'civicrm_extension',
201 'entity' => 'Extension',
202 'bao' => 'CRM_Core_BAO_Extension',
203 'localizable' => 0,
204 'add' => '4.2',
205 ],
206 'schema_version' => [
207 'name' => 'schema_version',
208 'type' => CRM_Utils_Type::T_STRING,
209 'title' => ts('Schema Version'),
210 'description' => ts('Revision code of the database schema; the format is module-defined'),
211 'maxlength' => 63,
212 'size' => CRM_Utils_Type::BIG,
213 'import' => TRUE,
214 'where' => 'civicrm_extension.schema_version',
215 'export' => TRUE,
216 'table_name' => 'civicrm_extension',
217 'entity' => 'Extension',
218 'bao' => 'CRM_Core_BAO_Extension',
219 'localizable' => 0,
220 'add' => '4.2',
221 ],
222 'is_active' => [
223 'name' => 'is_active',
224 'type' => CRM_Utils_Type::T_BOOLEAN,
225 'title' => ts('Extension is Active?'),
226 'description' => ts('Is this extension active?'),
227 'where' => 'civicrm_extension.is_active',
228 'default' => '1',
229 'table_name' => 'civicrm_extension',
230 'entity' => 'Extension',
231 'bao' => 'CRM_Core_BAO_Extension',
232 'localizable' => 0,
233 'add' => '4.2',
234 ],
235 ];
236 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
237 }
238 return Civi::$statics[__CLASS__]['fields'];
239 }
240
241 /**
242 * Return a mapping from field-name to the corresponding key (as used in fields()).
243 *
244 * @return array
245 * Array(string $name => string $uniqueName).
246 */
247 public static function &fieldKeys() {
248 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
249 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
250 }
251 return Civi::$statics[__CLASS__]['fieldKeys'];
252 }
253
254 /**
255 * Returns the names of this table
256 *
257 * @return string
258 */
259 public static function getTableName() {
260 return self::$_tableName;
261 }
262
263 /**
264 * Returns if this table needs to be logged
265 *
266 * @return bool
267 */
268 public function getLog() {
269 return self::$_log;
270 }
271
272 /**
273 * Returns the list of fields that can be imported
274 *
275 * @param bool $prefix
276 *
277 * @return array
278 */
279 public static function &import($prefix = FALSE) {
280 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'extension', $prefix, []);
281 return $r;
282 }
283
284 /**
285 * Returns the list of fields that can be exported
286 *
287 * @param bool $prefix
288 *
289 * @return array
290 */
291 public static function &export($prefix = FALSE) {
292 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'extension', $prefix, []);
293 return $r;
294 }
295
296 /**
297 * Returns the list of indices
298 *
299 * @param bool $localize
300 *
301 * @return array
302 */
303 public static function indices($localize = TRUE) {
304 $indices = [
305 'UI_extension_full_name' => [
306 'name' => 'UI_extension_full_name',
307 'field' => [
308 0 => 'full_name',
309 ],
310 'localizable' => FALSE,
311 'unique' => TRUE,
312 'sig' => 'civicrm_extension::1::full_name',
313 ],
314 'UI_extension_name' => [
315 'name' => 'UI_extension_name',
316 'field' => [
317 0 => 'name',
318 ],
319 'localizable' => FALSE,
320 'sig' => 'civicrm_extension::0::name',
321 ],
322 ];
323 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
324 }
325
326 }