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