Merge pull request #14302 from mlutfy/drupal19
[civicrm-core.git] / CRM / Core / DAO / OptionGroup.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/OptionGroup.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:c9ed24515dcc4ce676fb21518bd90791)
10 */
11
12 /**
13 * Database access object for the OptionGroup entity.
14 */
15 class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_option_group';
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 = TRUE;
30
31 /**
32 * Option Group ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.
40 *
41 * @var string
42 */
43 public $name;
44
45 /**
46 * Option Group title.
47 *
48 * @var string
49 */
50 public $title;
51
52 /**
53 * Option group description.
54 *
55 * @var string
56 */
57 public $description;
58
59 /**
60 * Option group description.
61 *
62 * @var string
63 */
64 public $data_type;
65
66 /**
67 * Is this a predefined system option group (i.e. it can not be deleted)?
68 *
69 * @var bool
70 */
71 public $is_reserved;
72
73 /**
74 * Is this option group active?
75 *
76 * @var bool
77 */
78 public $is_active;
79
80 /**
81 * A lock to remove the ability to add new options via the UI.
82 *
83 * @var bool
84 */
85 public $is_locked;
86
87 /**
88 * Class constructor.
89 */
90 public function __construct() {
91 $this->__table = 'civicrm_option_group';
92 parent::__construct();
93 }
94
95 /**
96 * Returns all the column names of this table
97 *
98 * @return array
99 */
100 public static function &fields() {
101 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
102 Civi::$statics[__CLASS__]['fields'] = [
103 'id' => [
104 'name' => 'id',
105 'type' => CRM_Utils_Type::T_INT,
106 'title' => ts('Option Group ID'),
107 'description' => ts('Option Group ID'),
108 'required' => TRUE,
109 'where' => 'civicrm_option_group.id',
110 'table_name' => 'civicrm_option_group',
111 'entity' => 'OptionGroup',
112 'bao' => 'CRM_Core_BAO_OptionGroup',
113 'localizable' => 0,
114 ],
115 'name' => [
116 'name' => 'name',
117 'type' => CRM_Utils_Type::T_STRING,
118 'title' => ts('Option Group Name'),
119 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'),
120 'required' => TRUE,
121 'maxlength' => 64,
122 'size' => CRM_Utils_Type::BIG,
123 'where' => 'civicrm_option_group.name',
124 'table_name' => 'civicrm_option_group',
125 'entity' => 'OptionGroup',
126 'bao' => 'CRM_Core_BAO_OptionGroup',
127 'localizable' => 0,
128 ],
129 'title' => [
130 'name' => 'title',
131 'type' => CRM_Utils_Type::T_STRING,
132 'title' => ts('Option Group title'),
133 'description' => ts('Option Group title.'),
134 'maxlength' => 255,
135 'size' => CRM_Utils_Type::HUGE,
136 'where' => 'civicrm_option_group.title',
137 'table_name' => 'civicrm_option_group',
138 'entity' => 'OptionGroup',
139 'bao' => 'CRM_Core_BAO_OptionGroup',
140 'localizable' => 1,
141 ],
142 'description' => [
143 'name' => 'description',
144 'type' => CRM_Utils_Type::T_STRING,
145 'title' => ts('Option Group Description'),
146 'description' => ts('Option group description.'),
147 'maxlength' => 255,
148 'size' => CRM_Utils_Type::HUGE,
149 'where' => 'civicrm_option_group.description',
150 'table_name' => 'civicrm_option_group',
151 'entity' => 'OptionGroup',
152 'bao' => 'CRM_Core_BAO_OptionGroup',
153 'localizable' => 1,
154 ],
155 'data_type' => [
156 'name' => 'data_type',
157 'type' => CRM_Utils_Type::T_STRING,
158 'title' => ts('Data Type for this option group'),
159 'description' => ts('Option group description.'),
160 'maxlength' => 128,
161 'size' => CRM_Utils_Type::HUGE,
162 'where' => 'civicrm_option_group.data_type',
163 'table_name' => 'civicrm_option_group',
164 'entity' => 'OptionGroup',
165 'bao' => 'CRM_Core_BAO_OptionGroup',
166 'localizable' => 0,
167 'pseudoconstant' => [
168 'callback' => 'CRM_Utils_Type::dataTypes',
169 ],
170 ],
171 'is_reserved' => [
172 'name' => 'is_reserved',
173 'type' => CRM_Utils_Type::T_BOOLEAN,
174 'title' => ts('Option Group Is Reserved?'),
175 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'),
176 'required' => TRUE,
177 'where' => 'civicrm_option_group.is_reserved',
178 'default' => '1',
179 'table_name' => 'civicrm_option_group',
180 'entity' => 'OptionGroup',
181 'bao' => 'CRM_Core_BAO_OptionGroup',
182 'localizable' => 0,
183 ],
184 'is_active' => [
185 'name' => 'is_active',
186 'type' => CRM_Utils_Type::T_BOOLEAN,
187 'title' => ts('Option Group Is Active?'),
188 'description' => ts('Is this option group active?'),
189 'required' => TRUE,
190 'where' => 'civicrm_option_group.is_active',
191 'default' => '1',
192 'table_name' => 'civicrm_option_group',
193 'entity' => 'OptionGroup',
194 'bao' => 'CRM_Core_BAO_OptionGroup',
195 'localizable' => 0,
196 ],
197 'is_locked' => [
198 'name' => 'is_locked',
199 'type' => CRM_Utils_Type::T_BOOLEAN,
200 'title' => ts('Option Group Is Locked'),
201 'description' => ts('A lock to remove the ability to add new options via the UI.'),
202 'required' => TRUE,
203 'where' => 'civicrm_option_group.is_locked',
204 'default' => '0',
205 'table_name' => 'civicrm_option_group',
206 'entity' => 'OptionGroup',
207 'bao' => 'CRM_Core_BAO_OptionGroup',
208 'localizable' => 0,
209 ],
210 ];
211 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
212 }
213 return Civi::$statics[__CLASS__]['fields'];
214 }
215
216 /**
217 * Return a mapping from field-name to the corresponding key (as used in fields()).
218 *
219 * @return array
220 * Array(string $name => string $uniqueName).
221 */
222 public static function &fieldKeys() {
223 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
224 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
225 }
226 return Civi::$statics[__CLASS__]['fieldKeys'];
227 }
228
229 /**
230 * Returns the names of this table
231 *
232 * @return string
233 */
234 public static function getTableName() {
235 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
236 }
237
238 /**
239 * Returns if this table needs to be logged
240 *
241 * @return bool
242 */
243 public function getLog() {
244 return self::$_log;
245 }
246
247 /**
248 * Returns the list of fields that can be imported
249 *
250 * @param bool $prefix
251 *
252 * @return array
253 */
254 public static function &import($prefix = FALSE) {
255 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_group', $prefix, []);
256 return $r;
257 }
258
259 /**
260 * Returns the list of fields that can be exported
261 *
262 * @param bool $prefix
263 *
264 * @return array
265 */
266 public static function &export($prefix = FALSE) {
267 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_group', $prefix, []);
268 return $r;
269 }
270
271 /**
272 * Returns the list of indices
273 *
274 * @param bool $localize
275 *
276 * @return array
277 */
278 public static function indices($localize = TRUE) {
279 $indices = [
280 'UI_name' => [
281 'name' => 'UI_name',
282 'field' => [
283 0 => 'name',
284 ],
285 'localizable' => FALSE,
286 'unique' => TRUE,
287 'sig' => 'civicrm_option_group::1::name',
288 ],
289 ];
290 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
291 }
292
293 }