Merge pull request #19329 from civicrm/5.33
[civicrm-core.git] / CRM / Core / DAO / Component.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Component.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:3b686ef7dde6f66dfe5eb708e667dcc7)
10 */
11
12 /**
13 * Database access object for the Component entity.
14 */
15 class CRM_Core_DAO_Component extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '2.0';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_component';
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 * Component ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Name of the component.
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * Path to components main directory in a form of a class namespace.
49 *
50 * @var string
51 */
52 public $namespace;
53
54 /**
55 * Class constructor.
56 */
57 public function __construct() {
58 $this->__table = 'civicrm_component';
59 parent::__construct();
60 }
61
62 /**
63 * Returns localized title of this entity.
64 *
65 * @param bool $plural
66 * Whether to return the plural version of the title.
67 */
68 public static function getEntityTitle($plural = FALSE) {
69 return $plural ? ts('Components') : ts('Component');
70 }
71
72 /**
73 * Returns all the column names of this table
74 *
75 * @return array
76 */
77 public static function &fields() {
78 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
79 Civi::$statics[__CLASS__]['fields'] = [
80 'id' => [
81 'name' => 'id',
82 'type' => CRM_Utils_Type::T_INT,
83 'title' => ts('Component ID'),
84 'description' => ts('Component ID'),
85 'required' => TRUE,
86 'where' => 'civicrm_component.id',
87 'table_name' => 'civicrm_component',
88 'entity' => 'Component',
89 'bao' => 'CRM_Core_DAO_Component',
90 'localizable' => 0,
91 'add' => '2.0',
92 ],
93 'name' => [
94 'name' => 'name',
95 'type' => CRM_Utils_Type::T_STRING,
96 'title' => ts('Component name'),
97 'description' => ts('Name of the component.'),
98 'required' => TRUE,
99 'maxlength' => 64,
100 'size' => CRM_Utils_Type::BIG,
101 'where' => 'civicrm_component.name',
102 'table_name' => 'civicrm_component',
103 'entity' => 'Component',
104 'bao' => 'CRM_Core_DAO_Component',
105 'localizable' => 0,
106 'add' => '2.0',
107 ],
108 'namespace' => [
109 'name' => 'namespace',
110 'type' => CRM_Utils_Type::T_STRING,
111 'title' => ts('Namespace reserved for component.'),
112 'description' => ts('Path to components main directory in a form of a class namespace.'),
113 'maxlength' => 128,
114 'size' => CRM_Utils_Type::HUGE,
115 'where' => 'civicrm_component.namespace',
116 'table_name' => 'civicrm_component',
117 'entity' => 'Component',
118 'bao' => 'CRM_Core_DAO_Component',
119 'localizable' => 0,
120 'add' => '2.0',
121 ],
122 ];
123 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
124 }
125 return Civi::$statics[__CLASS__]['fields'];
126 }
127
128 /**
129 * Return a mapping from field-name to the corresponding key (as used in fields()).
130 *
131 * @return array
132 * Array(string $name => string $uniqueName).
133 */
134 public static function &fieldKeys() {
135 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
136 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
137 }
138 return Civi::$statics[__CLASS__]['fieldKeys'];
139 }
140
141 /**
142 * Returns the names of this table
143 *
144 * @return string
145 */
146 public static function getTableName() {
147 return self::$_tableName;
148 }
149
150 /**
151 * Returns if this table needs to be logged
152 *
153 * @return bool
154 */
155 public function getLog() {
156 return self::$_log;
157 }
158
159 /**
160 * Returns the list of fields that can be imported
161 *
162 * @param bool $prefix
163 *
164 * @return array
165 */
166 public static function &import($prefix = FALSE) {
167 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'component', $prefix, []);
168 return $r;
169 }
170
171 /**
172 * Returns the list of fields that can be exported
173 *
174 * @param bool $prefix
175 *
176 * @return array
177 */
178 public static function &export($prefix = FALSE) {
179 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'component', $prefix, []);
180 return $r;
181 }
182
183 /**
184 * Returns the list of indices
185 *
186 * @param bool $localize
187 *
188 * @return array
189 */
190 public static function indices($localize = TRUE) {
191 $indices = [];
192 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
193 }
194
195 }