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