*
* Generated from xml/schema/CRM/Contact/RelationshipCache.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:3bee16c8388728d3e391e9dd7c17abb8)
+ * (GenCodeChecksum:ba039fcadc13e48749f965343301ec1d)
*/
/**
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
- return $plural ? ts('Relationship Caches') : ts('Relationship Cache');
+ return $plural ? ts('Related Contacts') : ts('Related Contact');
}
/**
'near_relation' => [
'name' => 'near_relation',
'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Relationship Name (Near side)'),
+ 'title' => ts('Relationship Name (to related contact)'),
'description' => ts('name for relationship of near_contact to far_contact.'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
'far_relation' => [
'name' => 'far_relation',
'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Relationship Name (Near side)'),
+ 'title' => ts('Relationship Name (from related contact)'),
'description' => ts('name for relationship of far_contact to near_contact.'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
* Returns list of FK relationships.
*
*
- * @return array
- * Array of CRM_Core_Reference_Interface
+ * @return CRM_Core_Reference_Basic[]
*/
public static function getReferenceColumns() {
return [];
'data_type' => 'Array',
'description' => 'Any @see annotations from docblock',
],
+ [
+ 'name' => 'bridge',
+ 'data_type' => 'Array',
+ 'description' => 'Connecting fields for EntityBridge types',
+ ],
];
}))->setCheckPermissions($checkPermissions);
}
* @return string
*/
protected static function getEntityTitle($plural = FALSE) {
- return static::getEntityName();
+ $name = static::getEntityName();
+ $dao = \CRM_Core_DAO_AllCoreTables::getFullName($name);
+ return $dao ? $dao::getEntityTitle($plural) : ($plural ? \CRM_Utils_String::pluralize($name) : $name);
}
/**
'type' => [self::stripNamespace(get_parent_class(static::class))],
'paths' => static::getEntityPaths(),
];
+ // Add info for entities with a corresponding DAO
+ $dao = \CRM_Core_DAO_AllCoreTables::getFullName($info['name']);
+ if ($dao) {
+ $info['paths'] = $dao::getEntityPaths();
+ $info['icon'] = $dao::$_icon;
+ $info['dao'] = $dao;
+ }
foreach (ReflectionUtils::getTraits(static::class) as $trait) {
$info['type'][] = self::stripNamespace($trait);
}
->setCheckPermissions($checkPermissions);
}
- /**
- * @param bool $plural
- * Whether to return a plural title.
- * @return string
- */
- protected static function getEntityTitle($plural = FALSE) {
- $name = static::getEntityName();
- $dao = \CRM_Core_DAO_AllCoreTables::getFullName($name);
- return $dao ? $dao::getEntityTitle($plural) : $name;
- }
-
- /**
- * @return array
- */
- public static function getInfo() {
- $info = parent::getInfo();
- $dao = \CRM_Core_DAO_AllCoreTables::getFullName($info['name']);
- if ($dao) {
- $info['paths'] = $dao::getEntityPaths();
- $info['icon'] = $dao::$_icon;
- $info['dao'] = $dao;
- }
- return $info;
- }
-
}
*/
trait EntityBridge {
+ /**
+ * Adds "bridge" info, which should specify an array of two field names from this entity
+ *
+ * This automatic function can be overridden by annotating the APIv4 entity like
+ * `@bridge contact_id group_id`
+ *
+ * @return array
+ */
+ public static function getInfo() {
+ $info = parent::getInfo();
+ if (!empty($info['dao']) && empty($info['bridge'])) {
+ foreach (($info['dao'])::fields() as $field) {
+ if (!empty($field['FKClassName']) || $field['name'] === 'entity_id') {
+ $info['bridge'][] = $field['name'];
+ }
+ }
+ }
+ return $info;
+ }
+
}
* A contact can either be "Added" "Removed" or "Pending" in a group.
* CiviCRM only considers them to be "in" a group if their status is "Added".
*
+ * @bridge group_id contact_id
* @see \Civi\Api4\Group
- *
+ * @searchable false
* @package Civi\Api4
*/
class GroupContact extends Generic\DAOEntity {
* RelationshipCache - readonly table to facilitate joining and finding contacts by relationship.
*
* @see \Civi\Api4\Relationship
- *
+ * @bridge near_contact_id far_contact_id
* @package Civi\Api4
*/
class RelationshipCache extends Generic\AbstractEntity {
elseif ($key == 'searchable') {
$info[$key] = strtolower($words[0]) !== 'false';
}
+ elseif ($key == 'bridge') {
+ $info[$key] = $words;
+ }
elseif ($key == 'param' && $words) {
$type = $words[0][0] !== '$' ? explode('|', array_shift($words)) : NULL;
$param = rtrim(array_shift($words), '-:()/');
<add>5.29</add>
<log>false</log>
<icon>fa-handshake-o</icon>
-
+ <title>Related Contact</title>
<field>
<name>id</name>
<type>int unsigned</type>
<field>
<name>near_relation</name>
<type>varchar</type>
- <title>Relationship Name (Near side)</title>
+ <title>Relationship Name (to related contact)</title>
<length>64</length>
<comment>name for relationship of near_contact to far_contact.</comment>
<add>5.29</add>
<field>
<name>far_relation</name>
<type>varchar</type>
- <title>Relationship Name (Near side)</title>
+ <title>Relationship Name (from related contact)</title>
<length>64</length>
<comment>name for relationship of far_contact to near_contact.</comment>
<add>5.29</add>