Merge pull request #22155 from eileenmcnaughton/n4
[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:fd26fa740989a13ac1d91618c2059d57)
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 'html' => [
92 'type' => 'Number',
93 ],
94 'readonly' => TRUE,
95 'add' => '2.0',
96 ],
97 'name' => [
98 'name' => 'name',
99 'type' => CRM_Utils_Type::T_STRING,
100 'title' => ts('Component name'),
101 'description' => ts('Name of the component.'),
102 'required' => TRUE,
103 'maxlength' => 64,
104 'size' => CRM_Utils_Type::BIG,
105 'where' => 'civicrm_component.name',
106 'table_name' => 'civicrm_component',
107 'entity' => 'Component',
108 'bao' => 'CRM_Core_DAO_Component',
109 'localizable' => 0,
110 'add' => '2.0',
111 ],
112 'namespace' => [
113 'name' => 'namespace',
114 'type' => CRM_Utils_Type::T_STRING,
115 'title' => ts('Namespace reserved for component.'),
116 'description' => ts('Path to components main directory in a form of a class namespace.'),
117 'maxlength' => 128,
118 'size' => CRM_Utils_Type::HUGE,
119 'where' => 'civicrm_component.namespace',
120 'table_name' => 'civicrm_component',
121 'entity' => 'Component',
122 'bao' => 'CRM_Core_DAO_Component',
123 'localizable' => 0,
124 'add' => '2.0',
125 ],
126 ];
127 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
128 }
129 return Civi::$statics[__CLASS__]['fields'];
130 }
131
132 /**
133 * Return a mapping from field-name to the corresponding key (as used in fields()).
134 *
135 * @return array
136 * Array(string $name => string $uniqueName).
137 */
138 public static function &fieldKeys() {
139 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
140 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
141 }
142 return Civi::$statics[__CLASS__]['fieldKeys'];
143 }
144
145 /**
146 * Returns the names of this table
147 *
148 * @return string
149 */
150 public static function getTableName() {
151 return self::$_tableName;
152 }
153
154 /**
155 * Returns if this table needs to be logged
156 *
157 * @return bool
158 */
159 public function getLog() {
160 return self::$_log;
161 }
162
163 /**
164 * Returns the list of fields that can be imported
165 *
166 * @param bool $prefix
167 *
168 * @return array
169 */
170 public static function &import($prefix = FALSE) {
171 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'component', $prefix, []);
172 return $r;
173 }
174
175 /**
176 * Returns the list of fields that can be exported
177 *
178 * @param bool $prefix
179 *
180 * @return array
181 */
182 public static function &export($prefix = FALSE) {
183 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'component', $prefix, []);
184 return $r;
185 }
186
187 /**
188 * Returns the list of indices
189 *
190 * @param bool $localize
191 *
192 * @return array
193 */
194 public static function indices($localize = TRUE) {
195 $indices = [];
196 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
197 }
198
199 }