+ /**
+ * Get default title for this item, based on the entity's `label_field`
+ *
+ * @param string $entityType
+ * @param int $entityId
+ * @return string|null
+ */
+ private static function getTitle($entityType, $entityId) {
+ $labelField = CoreUtil::getInfoItem($entityType, 'label_field');
+ $title = NULL;
+ if ($labelField) {
+ $record = civicrm_api4($entityType, 'get', [
+ 'where' => [['id', '=', $entityId]],
+ 'select' => [$labelField],
+ ], 0);
+ $title = $record[$labelField] ?? NULL;
+ }
+ return $title ?? (CoreUtil::getInfoItem($entityType, 'label_field'));
+ }
+
+ /**
+ * Get a link to view/update/delete a given entity.
+ *
+ * @param string $entityType
+ * @param int $entityId
+ * @param string $action
+ * Either 'view', 'update', or 'delete'
+ * @return string|null
+ */
+ private static function getUrl($entityType, $entityId, $action) {
+ if ($action !== 'view') {
+ $check = civicrm_api4($entityType, 'checkAccess', [
+ 'action' => $action,
+ 'values' => ['id' => $entityId],
+ ], 0);
+ if (empty($check['access'])) {
+ return NULL;
+ }
+ }
+ $paths = (array) CoreUtil::getInfoItem($entityType, 'paths');
+ if (!empty($paths[$action])) {
+ return CRM_Utils_System::url(str_replace('[id]', $entityId, $paths[$action]));
+ }
+ return NULL;
+ }
+
+ /**
+ * @param $entityType
+ * @param $entityId
+ * @return string|null
+ */
+ private static function getIcon($entityType, $entityId) {
+ $icon = NULL;
+ $daoClass = CRM_Core_DAO_AllCoreTables::getFullName($entityType);
+ if ($daoClass) {
+ $icon = CRM_Core_DAO_AllCoreTables::getBAOClassName($daoClass)::getEntityIcon($entityType, $entityId);
+ }
+ return $icon ?: 'fa-gear';
+ }
+