Merge pull request #22155 from eileenmcnaughton/n4
[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:8d9c173c0d7da38d4c28c6b712aecee0)
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 * @param bool $plural
99 * Whether to return the plural version of the title.
100 */
101 public static function getEntityTitle($plural = FALSE) {
102 return $plural ? ts('Extensions') : ts('Extension');
103 }
104
105 /**
106 * Returns all the column names of this table
107 *
108 * @return array
109 */
110 public static function &fields() {
111 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
112 Civi::$statics[__CLASS__]['fields'] = [
113 'id' => [
114 'name' => 'id',
115 'type' => CRM_Utils_Type::T_INT,
116 'title' => ts('Extension ID'),
117 'description' => ts('Local Extension ID'),
118 'required' => TRUE,
119 'where' => 'civicrm_extension.id',
120 'table_name' => 'civicrm_extension',
121 'entity' => 'Extension',
122 'bao' => 'CRM_Core_BAO_Extension',
123 'localizable' => 0,
124 'html' => [
125 'type' => 'Number',
126 ],
127 'readonly' => TRUE,
128 'add' => '4.2',
129 ],
130 'type' => [
131 'name' => 'type',
132 'type' => CRM_Utils_Type::T_STRING,
133 'title' => ts('Type'),
134 'required' => TRUE,
135 'maxlength' => 8,
136 'size' => CRM_Utils_Type::EIGHT,
137 'where' => 'civicrm_extension.type',
138 'table_name' => 'civicrm_extension',
139 'entity' => 'Extension',
140 'bao' => 'CRM_Core_BAO_Extension',
141 'localizable' => 0,
142 'html' => [
143 'type' => 'Select',
144 ],
145 'pseudoconstant' => [
146 'callback' => 'CRM_Core_SelectValues::getExtensionTypes',
147 ],
148 'add' => '4.2',
149 ],
150 'full_name' => [
151 'name' => 'full_name',
152 'type' => CRM_Utils_Type::T_STRING,
153 'title' => ts('Key'),
154 'description' => ts('Fully qualified extension name'),
155 'required' => TRUE,
156 'maxlength' => 255,
157 'size' => CRM_Utils_Type::HUGE,
158 'where' => 'civicrm_extension.full_name',
159 'table_name' => 'civicrm_extension',
160 'entity' => 'Extension',
161 'bao' => 'CRM_Core_BAO_Extension',
162 'localizable' => 0,
163 'add' => '4.2',
164 ],
165 'name' => [
166 'name' => 'name',
167 'type' => CRM_Utils_Type::T_STRING,
168 'title' => ts('Name'),
169 'description' => ts('Short name'),
170 'maxlength' => 255,
171 'size' => CRM_Utils_Type::HUGE,
172 'import' => TRUE,
173 'where' => 'civicrm_extension.name',
174 'export' => TRUE,
175 'table_name' => 'civicrm_extension',
176 'entity' => 'Extension',
177 'bao' => 'CRM_Core_BAO_Extension',
178 'localizable' => 0,
179 'add' => '4.2',
180 ],
181 'label' => [
182 'name' => 'label',
183 'type' => CRM_Utils_Type::T_STRING,
184 'title' => ts('Label'),
185 'description' => ts('Short, printable name'),
186 'maxlength' => 255,
187 'size' => CRM_Utils_Type::HUGE,
188 'import' => TRUE,
189 'where' => 'civicrm_extension.label',
190 'export' => TRUE,
191 'table_name' => 'civicrm_extension',
192 'entity' => 'Extension',
193 'bao' => 'CRM_Core_BAO_Extension',
194 'localizable' => 0,
195 'add' => '4.2',
196 ],
197 'file' => [
198 'name' => 'file',
199 'type' => CRM_Utils_Type::T_STRING,
200 'title' => ts('File'),
201 'description' => ts('Primary PHP file'),
202 'maxlength' => 255,
203 'size' => CRM_Utils_Type::HUGE,
204 'import' => TRUE,
205 'where' => 'civicrm_extension.file',
206 'export' => TRUE,
207 'table_name' => 'civicrm_extension',
208 'entity' => 'Extension',
209 'bao' => 'CRM_Core_BAO_Extension',
210 'localizable' => 0,
211 'add' => '4.2',
212 ],
213 'schema_version' => [
214 'name' => 'schema_version',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Schema Version'),
217 'description' => ts('Revision code of the database schema; the format is module-defined'),
218 'maxlength' => 63,
219 'size' => CRM_Utils_Type::BIG,
220 'import' => TRUE,
221 'where' => 'civicrm_extension.schema_version',
222 'export' => TRUE,
223 'table_name' => 'civicrm_extension',
224 'entity' => 'Extension',
225 'bao' => 'CRM_Core_BAO_Extension',
226 'localizable' => 0,
227 'add' => '4.2',
228 ],
229 'is_active' => [
230 'name' => 'is_active',
231 'type' => CRM_Utils_Type::T_BOOLEAN,
232 'title' => ts('Extension is Active?'),
233 'description' => ts('Is this extension active?'),
234 'where' => 'civicrm_extension.is_active',
235 'default' => '1',
236 'table_name' => 'civicrm_extension',
237 'entity' => 'Extension',
238 'bao' => 'CRM_Core_BAO_Extension',
239 'localizable' => 0,
240 'add' => '4.2',
241 ],
242 ];
243 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
244 }
245 return Civi::$statics[__CLASS__]['fields'];
246 }
247
248 /**
249 * Return a mapping from field-name to the corresponding key (as used in fields()).
250 *
251 * @return array
252 * Array(string $name => string $uniqueName).
253 */
254 public static function &fieldKeys() {
255 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
256 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
257 }
258 return Civi::$statics[__CLASS__]['fieldKeys'];
259 }
260
261 /**
262 * Returns the names of this table
263 *
264 * @return string
265 */
266 public static function getTableName() {
267 return self::$_tableName;
268 }
269
270 /**
271 * Returns if this table needs to be logged
272 *
273 * @return bool
274 */
275 public function getLog() {
276 return self::$_log;
277 }
278
279 /**
280 * Returns the list of fields that can be imported
281 *
282 * @param bool $prefix
283 *
284 * @return array
285 */
286 public static function &import($prefix = FALSE) {
287 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'extension', $prefix, []);
288 return $r;
289 }
290
291 /**
292 * Returns the list of fields that can be exported
293 *
294 * @param bool $prefix
295 *
296 * @return array
297 */
298 public static function &export($prefix = FALSE) {
299 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'extension', $prefix, []);
300 return $r;
301 }
302
303 /**
304 * Returns the list of indices
305 *
306 * @param bool $localize
307 *
308 * @return array
309 */
310 public static function indices($localize = TRUE) {
311 $indices = [
312 'UI_extension_full_name' => [
313 'name' => 'UI_extension_full_name',
314 'field' => [
315 0 => 'full_name',
316 ],
317 'localizable' => FALSE,
318 'unique' => TRUE,
319 'sig' => 'civicrm_extension::1::full_name',
320 ],
321 'UI_extension_name' => [
322 'name' => 'UI_extension_name',
323 'field' => [
324 0 => 'name',
325 ],
326 'localizable' => FALSE,
327 'sig' => 'civicrm_extension::0::name',
328 ],
329 ];
330 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
331 }
332
333 }