/**
* Returns localized title of this entity.
+ *
* @return string
*/
public static function getEntityTitle() {
$className = static::class;
- Civi::log()->warning("$className needs to be regeneraged. Missing getEntityTitle method.", ['civi.tag' => 'deprecated']);
+ Civi::log()->warning("$className needs to be regenerated. Missing getEntityTitle method.", ['civi.tag' => 'deprecated']);
return CRM_Core_DAO_AllCoreTables::getBriefName($className);
}
}
/**
- * Empty definition for virtual function.
+ * Returns the name of this table
+ *
+ * @return string
*/
public static function getTableName() {
- return NULL;
+ return self::getLocaleTableName(static::$_tableName ?? NULL);
+ }
+
+ /**
+ * Returns if this table needs to be logged
+ *
+ * @return bool
+ */
+ public function getLog() {
+ return static::$_log ?? FALSE;
}
/**
else {
$maxLength = $field['maxlength'] ?? NULL;
if (!is_array($value) && $maxLength && mb_strlen($value) > $maxLength && empty($field['pseudoconstant'])) {
- Civi::log()->warning(ts('A string for field $dbName has been truncated. The original string was %1', [CRM_Utils_Type::escape($value, 'String')]));
- // The string is too long - what to do what to do? Well losing data is generally bad so lets' truncate
+ // No ts() since this is a sysadmin-y string not seen by general users.
+ Civi::log()->warning('A string for field {dbName} has been truncated. The original string was {value}.', ['dbName' => $dbName, 'value' => $value]);
+ // The string is too long - what to do what to do? Well losing data is generally bad so let's truncate
$value = CRM_Utils_String::ellipsify($value, $maxLength);
}
$this->$dbName = $value;
*/
public function getFieldSpec($fieldName) {
$fields = $this->fields();
- $fieldKeys = $this->fieldKeys();
// Support "unique names" as well as sql names
$fieldKey = $fieldName;
if (empty($fields[$fieldKey])) {
+ $fieldKeys = $this->fieldKeys();
$fieldKey = $fieldKeys[$fieldName] ?? NULL;
}
// If neither worked then this field doesn't exist. Return false.
}
}
+ /**
+ * Return a mapping from field-name to the corresponding key (as used in fields()).
+ *
+ * @return array
+ * Array(string $name => string $uniqueName).
+ */
+ public static function fieldKeys() {
+ return array_flip(CRM_Utils_Array::collect('name', static::fields()));
+ }
+
+ /**
+ * Returns system paths related to this entity (as defined in the xml schema)
+ *
+ * @return array
+ */
+ public static function getEntityPaths() {
+ return static::$_paths ?? [];
+ }
+
}