From aa998597498411d97d304da2a8cc5ed3c6dcdcc4 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 27 May 2021 16:01:25 -0400 Subject: [PATCH] SearchKit - Change @searchable annotation from boolean to option list In preparation for showing different tiers of entities, make this a string instead of a boolean property, to mark searchability as 'primary', 'secondary', or 'none'. --- Civi/Api4/ACL.php | 2 +- Civi/Api4/ActionSchedule.php | 2 +- Civi/Api4/Activity.php | 1 + Civi/Api4/Address.php | 1 + Civi/Api4/Batch.php | 1 + Civi/Api4/Campaign.php | 1 + Civi/Api4/CiviCase.php | 1 + Civi/Api4/Contact.php | 1 + Civi/Api4/Contribution.php | 1 + Civi/Api4/ContributionPage.php | 1 + Civi/Api4/ContributionRecur.php | 1 + Civi/Api4/ContributionSoft.php | 1 + Civi/Api4/CustomField.php | 2 +- Civi/Api4/CustomGroup.php | 2 +- Civi/Api4/CustomValue.php | 2 +- Civi/Api4/Dashboard.php | 2 +- Civi/Api4/DashboardContact.php | 2 +- Civi/Api4/Domain.php | 2 +- Civi/Api4/Email.php | 1 + Civi/Api4/Entity.php | 8 +++++++- Civi/Api4/Event.php | 1 + Civi/Api4/FinancialAccount.php | 1 + Civi/Api4/FinancialTrxn.php | 1 + Civi/Api4/FinancialType.php | 1 + Civi/Api4/Generic/AbstractEntity.php | 2 +- Civi/Api4/Generic/Traits/OptionList.php | 2 +- Civi/Api4/Grant.php | 1 + Civi/Api4/Group.php | 1 + Civi/Api4/GroupNesting.php | 2 +- Civi/Api4/GroupOrganization.php | 2 +- Civi/Api4/IM.php | 1 + Civi/Api4/LineItem.php | 1 + Civi/Api4/LocBlock.php | 2 +- Civi/Api4/MailSettings.php | 2 +- Civi/Api4/Mapping.php | 2 +- Civi/Api4/MappingField.php | 2 +- Civi/Api4/MessageTemplate.php | 2 +- Civi/Api4/Navigation.php | 2 +- Civi/Api4/Note.php | 1 + Civi/Api4/OpenID.php | 1 + Civi/Api4/PCPBlock.php | 1 + Civi/Api4/Participant.php | 1 + Civi/Api4/Permission.php | 2 +- Civi/Api4/Phone.php | 1 + Civi/Api4/PledgePayment.php | 1 + Civi/Api4/PriceField.php | 1 + Civi/Api4/PriceFieldValue.php | 1 + Civi/Api4/PriceSet.php | 1 + Civi/Api4/Relationship.php | 2 +- Civi/Api4/Route.php | 2 +- Civi/Api4/SavedSearch.php | 2 +- Civi/Api4/Setting.php | 2 +- Civi/Api4/StatusPreference.php | 2 +- Civi/Api4/System.php | 1 + Civi/Api4/Tag.php | 1 + Civi/Api4/UFField.php | 2 +- Civi/Api4/UFGroup.php | 2 +- Civi/Api4/UFJoin.php | 2 +- Civi/Api4/UFMatch.php | 2 +- Civi/Api4/Utils/ReflectionUtils.php | 3 --- Civi/Api4/Website.php | 1 + ext/afform/core/Civi/Api4/Afform.php | 2 +- ext/search_kit/Civi/Api4/SearchDisplay.php | 2 +- ext/search_kit/Civi/Search/Admin.php | 4 ++-- tests/phpunit/api/v4/Entity/ConformanceTest.php | 1 + 65 files changed, 71 insertions(+), 36 deletions(-) diff --git a/Civi/Api4/ACL.php b/Civi/Api4/ACL.php index 01de7979ea..df7ac101a1 100644 --- a/Civi/Api4/ACL.php +++ b/Civi/Api4/ACL.php @@ -30,7 +30,7 @@ namespace Civi\Api4; * * Creating a new ACL requires at minimum an entity table, entity ID and object_table. * - * @searchable false + * @searchable none * @see https://docs.civicrm.org/user/en/latest/initial-set-up/permissions-and-access-control * @package Civi\Api4 */ diff --git a/Civi/Api4/ActionSchedule.php b/Civi/Api4/ActionSchedule.php index 2451af4292..4f2a6f1fe3 100644 --- a/Civi/Api4/ActionSchedule.php +++ b/Civi/Api4/ActionSchedule.php @@ -28,7 +28,7 @@ namespace Civi\Api4; * * Creating a new ActionSchedule requires at minimum a title, mapping_id and entity_value. * - * @searchable false + * @searchable none * @see https://docs.civicrm.org/user/en/latest/email/scheduled-reminders/ * @package Civi\Api4 */ diff --git a/Civi/Api4/Activity.php b/Civi/Api4/Activity.php index 4b45829273..8166c62825 100644 --- a/Civi/Api4/Activity.php +++ b/Civi/Api4/Activity.php @@ -30,6 +30,7 @@ namespace Civi\Api4; * An activity is a record of some type of interaction with one or more contacts. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/activities/ + * @searchable primary * @package Civi\Api4 */ class Activity extends Generic\DAOEntity { diff --git a/Civi/Api4/Address.php b/Civi/Api4/Address.php index 22c16323c9..a8e53641e6 100644 --- a/Civi/Api4/Address.php +++ b/Civi/Api4/Address.php @@ -30,6 +30,7 @@ namespace Civi\Api4; * * @ui_join_filters location_type_id * + * @searchable secondary * @package Civi\Api4 */ class Address extends Generic\DAOEntity { diff --git a/Civi/Api4/Batch.php b/Civi/Api4/Batch.php index 8a75875070..7e48003af6 100644 --- a/Civi/Api4/Batch.php +++ b/Civi/Api4/Batch.php @@ -22,6 +22,7 @@ namespace Civi\Api4; /** * Batch entity. * + * @searchable secondary * @see https://docs.civicrm.org/user/en/latest/pledges/everyday-tasks/#batch-entry-of-pledges * @package Civi\Api4 */ diff --git a/Civi/Api4/Campaign.php b/Civi/Api4/Campaign.php index 7d15c1b598..11e8834139 100644 --- a/Civi/Api4/Campaign.php +++ b/Civi/Api4/Campaign.php @@ -23,6 +23,7 @@ namespace Civi\Api4; * Campaign entity. * * @see https://docs.civicrm.org/user/en/latest/campaign/what-is-civicampaign/ + * @searchable secondary * @package Civi\Api4 */ class Campaign extends Generic\DAOEntity { diff --git a/Civi/Api4/CiviCase.php b/Civi/Api4/CiviCase.php index e1fb635c19..189dba867d 100644 --- a/Civi/Api4/CiviCase.php +++ b/Civi/Api4/CiviCase.php @@ -25,6 +25,7 @@ namespace Civi\Api4; * Note that the class for this entity is named "CiviCase" because "Case" is a keyword reserved by php. * * @see https://docs.civicrm.org/user/en/latest/case-management/what-is-civicase/ + * @searchable primary * @package Civi\Api4 */ class CiviCase extends Generic\DAOEntity { diff --git a/Civi/Api4/Contact.php b/Civi/Api4/Contact.php index 59abcc742e..9c24e00d75 100644 --- a/Civi/Api4/Contact.php +++ b/Civi/Api4/Contact.php @@ -28,6 +28,7 @@ namespace Civi\Api4; * Creating a new contact requires at minimum a name or email address. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/contacts/ + * @searchable primary * @package Civi\Api4 */ class Contact extends Generic\DAOEntity { diff --git a/Civi/Api4/Contribution.php b/Civi/Api4/Contribution.php index 99743ba015..fe7bc91624 100644 --- a/Civi/Api4/Contribution.php +++ b/Civi/Api4/Contribution.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * Contribution entity. * + * @searchable primary * @package Civi\Api4 */ class Contribution extends Generic\DAOEntity { diff --git a/Civi/Api4/ContributionPage.php b/Civi/Api4/ContributionPage.php index cfafb5b018..845780e7a0 100644 --- a/Civi/Api4/ContributionPage.php +++ b/Civi/Api4/ContributionPage.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * ContributionPage entity. * + * @searchable secondary * @package Civi\Api4 */ class ContributionPage extends Generic\DAOEntity { diff --git a/Civi/Api4/ContributionRecur.php b/Civi/Api4/ContributionRecur.php index 4d3884d15f..75380c7f0a 100644 --- a/Civi/Api4/ContributionRecur.php +++ b/Civi/Api4/ContributionRecur.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * ContributionRecur entity. * + * @searchable secondary * @package Civi\Api4 */ class ContributionRecur extends Generic\DAOEntity { diff --git a/Civi/Api4/ContributionSoft.php b/Civi/Api4/ContributionSoft.php index 17dc9fd05b..8271fa2225 100644 --- a/Civi/Api4/ContributionSoft.php +++ b/Civi/Api4/ContributionSoft.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * ContributionSoft entity. * + * @searchable secondary * @package Civi\Api4 */ class ContributionSoft extends Generic\DAOEntity { diff --git a/Civi/Api4/CustomField.php b/Civi/Api4/CustomField.php index 1d4b7e104b..2428efc93a 100644 --- a/Civi/Api4/CustomField.php +++ b/Civi/Api4/CustomField.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * CustomField entity. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class CustomField extends Generic\DAOEntity { diff --git a/Civi/Api4/CustomGroup.php b/Civi/Api4/CustomGroup.php index 7a87a2bde0..ba1729d82a 100644 --- a/Civi/Api4/CustomGroup.php +++ b/Civi/Api4/CustomGroup.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * CustomGroup entity. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class CustomGroup extends Generic\DAOEntity { diff --git a/Civi/Api4/CustomValue.php b/Civi/Api4/CustomValue.php index 8b9b3411db..40b4d96160 100644 --- a/Civi/Api4/CustomValue.php +++ b/Civi/Api4/CustomValue.php @@ -142,7 +142,7 @@ class CustomValue { return [ 'class' => __CLASS__, 'type' => ['CustomValue'], - 'searchable' => TRUE, + 'searchable' => 'secondary', 'see' => [ 'https://docs.civicrm.org/user/en/latest/organising-your-data/creating-custom-fields/#multiple-record-fieldsets', '\Civi\Api4\CustomGroup', diff --git a/Civi/Api4/Dashboard.php b/Civi/Api4/Dashboard.php index 24b42557a6..a8c424f19d 100644 --- a/Civi/Api4/Dashboard.php +++ b/Civi/Api4/Dashboard.php @@ -28,7 +28,7 @@ namespace Civi\Api4; * Displaying an item to a user is done with the `DashboardContact` entity. * * @see \Civi\Api4\DashboardContact - * @searchable false + * @searchable none * @package Civi\Api4 */ class Dashboard extends Generic\DAOEntity { diff --git a/Civi/Api4/DashboardContact.php b/Civi/Api4/DashboardContact.php index f2538b326c..d029f388d5 100644 --- a/Civi/Api4/DashboardContact.php +++ b/Civi/Api4/DashboardContact.php @@ -24,7 +24,7 @@ namespace Civi\Api4; * This places a dashboard item on a user's home screen. * * @see \Civi\Api4\Dashboard - * @searchable false + * @searchable none * @package Civi\Api4 */ class DashboardContact extends Generic\DAOEntity { diff --git a/Civi/Api4/Domain.php b/Civi/Api4/Domain.php index 8d356fac32..88e2df9eb5 100644 --- a/Civi/Api4/Domain.php +++ b/Civi/Api4/Domain.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * Domains - multisite instances of CiviCRM. * * @see https://docs.civicrm.org/sysadmin/en/latest/setup/multisite/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class Domain extends Generic\DAOEntity { diff --git a/Civi/Api4/Email.php b/Civi/Api4/Email.php index cfb9ef99e8..c9ec6d4bad 100644 --- a/Civi/Api4/Email.php +++ b/Civi/Api4/Email.php @@ -26,6 +26,7 @@ namespace Civi\Api4; * * Creating a new email address requires at minimum a contact's ID and email * + * @searchable secondary * @package Civi\Api4 */ class Email extends Generic\DAOEntity { diff --git a/Civi/Api4/Entity.php b/Civi/Api4/Entity.php index 31b3aeed6c..6f91044bd0 100644 --- a/Civi/Api4/Entity.php +++ b/Civi/Api4/Entity.php @@ -24,6 +24,7 @@ namespace Civi\Api4; * * @see \Civi\Api4\Generic\AbstractEntity * + * @searchable none * @package Civi\Api4 */ class Entity extends Generic\AbstractEntity { @@ -90,7 +91,12 @@ class Entity extends Generic\AbstractEntity { ], [ 'name' => 'searchable', - 'description' => 'Should this entity be selectable in search kit UI', + 'description' => 'How should this entity be presented in search UIs', + 'options' => [ + 'primary' => ts('Primary'), + 'secondary' => ts('Secondary'), + 'none' => ts('None'), + ], ], [ 'name' => 'paths', diff --git a/Civi/Api4/Event.php b/Civi/Api4/Event.php index 66c504a534..021ebc9818 100644 --- a/Civi/Api4/Event.php +++ b/Civi/Api4/Event.php @@ -24,6 +24,7 @@ namespace Civi\Api4; * * @see https://docs.civicrm.org/user/en/latest/events/what-is-civievent/ * + * @searchable primary * @package Civi\Api4 */ class Event extends Generic\DAOEntity { diff --git a/Civi/Api4/FinancialAccount.php b/Civi/Api4/FinancialAccount.php index 53bb3af33f..04b1dd821a 100644 --- a/Civi/Api4/FinancialAccount.php +++ b/Civi/Api4/FinancialAccount.php @@ -25,6 +25,7 @@ namespace Civi\Api4; * * @see https://docs.civicrm.org/user/en/latest/contributions/key-concepts-and-configurations/#financial-types-financial-accounts-and-accounting-codes * + * @searchable secondary * @package Civi\Api4 */ class FinancialAccount extends Generic\DAOEntity { diff --git a/Civi/Api4/FinancialTrxn.php b/Civi/Api4/FinancialTrxn.php index eafd153047..f04a37e399 100644 --- a/Civi/Api4/FinancialTrxn.php +++ b/Civi/Api4/FinancialTrxn.php @@ -28,6 +28,7 @@ namespace Civi\Api4; * * @see https://docs.civicrm.org/dev/en/latest/financial/financialentities/#financial-transactions * + * @searchable secondary * @package Civi\Api4 */ class FinancialTrxn extends Generic\DAOEntity { diff --git a/Civi/Api4/FinancialType.php b/Civi/Api4/FinancialType.php index 1c6bbaac94..d5dab2d39e 100644 --- a/Civi/Api4/FinancialType.php +++ b/Civi/Api4/FinancialType.php @@ -28,5 +28,6 @@ namespace Civi\Api4; * @package Civi\Api4 */ class FinancialType extends Generic\DAOEntity { + use Generic\Traits\OptionList; } diff --git a/Civi/Api4/Generic/AbstractEntity.php b/Civi/Api4/Generic/AbstractEntity.php index 754d33f387..182b51ff76 100644 --- a/Civi/Api4/Generic/AbstractEntity.php +++ b/Civi/Api4/Generic/AbstractEntity.php @@ -151,7 +151,7 @@ abstract class AbstractEntity { foreach (ReflectionUtils::getTraits(static::class) as $trait) { $info['type'][] = self::stripNamespace($trait); } - $info['searchable'] = !in_array('OptionList', $info['type']); + $info['searchable'] = in_array('OptionList', $info['type'], TRUE) ? 'none' : 'secondary'; $reflection = new \ReflectionClass(static::class); $info = array_merge($info, ReflectionUtils::getCodeDocs($reflection, NULL, ['entity' => $info['name']])); unset($info['package'], $info['method']); diff --git a/Civi/Api4/Generic/Traits/OptionList.php b/Civi/Api4/Generic/Traits/OptionList.php index 70936e0119..ff466d3d2a 100644 --- a/Civi/Api4/Generic/Traits/OptionList.php +++ b/Civi/Api4/Generic/Traits/OptionList.php @@ -17,7 +17,7 @@ namespace Civi\Api4\Generic\Traits; * The options appear in the field metadata for other entities that reference this one via pseudoconstant. * * Note: At time of writing, this trait does nothing except toggle the searchable flag, (and adds "OptionList" to the "type" in Entity::get() metadata). - * @searchable false (FYI annotation isn't functional because this is a trait - workaround in AbstractEntity::getInfo) + * @searchable none (FYI annotation isn't functional because this is a trait - workaround in AbstractEntity::getInfo) */ trait OptionList { diff --git a/Civi/Api4/Grant.php b/Civi/Api4/Grant.php index a0dc1dfd98..470672fc87 100644 --- a/Civi/Api4/Grant.php +++ b/Civi/Api4/Grant.php @@ -25,6 +25,7 @@ namespace Civi\Api4; * * @see https://docs.civicrm.org/user/en/latest/grants/what-is-civigrant/ * + * @searchable primary * @package Civi\Api4 */ class Grant extends Generic\DAOEntity { diff --git a/Civi/Api4/Group.php b/Civi/Api4/Group.php index 1b685361b0..4764d76b4d 100644 --- a/Civi/Api4/Group.php +++ b/Civi/Api4/Group.php @@ -23,6 +23,7 @@ namespace Civi\Api4; * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/groups-and-tags/#groups * + * @searchable secondary * @package Civi\Api4 */ class Group extends Generic\DAOEntity { diff --git a/Civi/Api4/GroupNesting.php b/Civi/Api4/GroupNesting.php index a8376088b9..b2428b1a65 100644 --- a/Civi/Api4/GroupNesting.php +++ b/Civi/Api4/GroupNesting.php @@ -22,7 +22,7 @@ namespace Civi\Api4; * GroupNesting entity. * * @see \Civi\Api4\Group - * @searchable false + * @searchable none * @package Civi\Api4 */ class GroupNesting extends Generic\DAOEntity { diff --git a/Civi/Api4/GroupOrganization.php b/Civi/Api4/GroupOrganization.php index f2f3bb2b38..c392cf91a4 100644 --- a/Civi/Api4/GroupOrganization.php +++ b/Civi/Api4/GroupOrganization.php @@ -24,7 +24,7 @@ namespace Civi\Api4; * Relates groups to organizations. * * FIXME: For now, excluding this from SearchKit because it's confusingly similar to GroupContact - * @searchable false + * @searchable none * * @see \Civi\Api4\Group * @package Civi\Api4 diff --git a/Civi/Api4/IM.php b/Civi/Api4/IM.php index ff39fabeb7..f563d3c717 100644 --- a/Civi/Api4/IM.php +++ b/Civi/Api4/IM.php @@ -22,6 +22,7 @@ namespace Civi\Api4; /** * IM entity. * + * @searchable secondary * @package Civi\Api4 */ class IM extends Generic\DAOEntity { diff --git a/Civi/Api4/LineItem.php b/Civi/Api4/LineItem.php index c630346a4b..724484be1e 100644 --- a/Civi/Api4/LineItem.php +++ b/Civi/Api4/LineItem.php @@ -21,6 +21,7 @@ namespace Civi\Api4; /** * LineItem entity. * + * @searchable secondary * @package Civi\Api4 */ class LineItem extends Generic\DAOEntity { diff --git a/Civi/Api4/LocBlock.php b/Civi/Api4/LocBlock.php index 03c2c9752c..d68c961ed1 100644 --- a/Civi/Api4/LocBlock.php +++ b/Civi/Api4/LocBlock.php @@ -17,7 +17,7 @@ namespace Civi\Api4; * * Links addresses, emails & phones to Events. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class LocBlock extends Generic\DAOEntity { diff --git a/Civi/Api4/MailSettings.php b/Civi/Api4/MailSettings.php index d2f6e5e0de..4730e8a18a 100644 --- a/Civi/Api4/MailSettings.php +++ b/Civi/Api4/MailSettings.php @@ -22,7 +22,7 @@ namespace Civi\Api4; /** * MailSettings entity. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class MailSettings extends Generic\DAOEntity { diff --git a/Civi/Api4/Mapping.php b/Civi/Api4/Mapping.php index 9c74f7d497..e7d6cbf11d 100644 --- a/Civi/Api4/Mapping.php +++ b/Civi/Api4/Mapping.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * * This is a collection of MappingFields, for reuse in import, export, etc. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class Mapping extends Generic\DAOEntity { diff --git a/Civi/Api4/MappingField.php b/Civi/Api4/MappingField.php index bde710c401..7e8b4ce4bc 100644 --- a/Civi/Api4/MappingField.php +++ b/Civi/Api4/MappingField.php @@ -24,7 +24,7 @@ namespace Civi\Api4; * This represents one field in a Mapping collection. * * @see \Civi\Api4\Mapping - * @searchable false + * @searchable none * @package Civi\Api4 */ class MappingField extends Generic\DAOEntity { diff --git a/Civi/Api4/MessageTemplate.php b/Civi/Api4/MessageTemplate.php index 5f05a517d5..d20f1054ec 100644 --- a/Civi/Api4/MessageTemplate.php +++ b/Civi/Api4/MessageTemplate.php @@ -22,7 +22,7 @@ namespace Civi\Api4; * MsgTemplate entity. * * This is a collection of MsgTemplate, for reuse in import, export, etc. - * @searchable false + * @searchable none * @package Civi\Api4 */ class MessageTemplate extends Generic\DAOEntity { diff --git a/Civi/Api4/Navigation.php b/Civi/Api4/Navigation.php index 57963db4e4..fd15888301 100644 --- a/Civi/Api4/Navigation.php +++ b/Civi/Api4/Navigation.php @@ -21,7 +21,7 @@ namespace Civi\Api4; /** * Navigation entity. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class Navigation extends Generic\DAOEntity { diff --git a/Civi/Api4/Note.php b/Civi/Api4/Note.php index 575a780a3e..baf205301f 100644 --- a/Civi/Api4/Note.php +++ b/Civi/Api4/Note.php @@ -22,6 +22,7 @@ namespace Civi\Api4; /** * Note entity. * + * @searchable secondary * @package Civi\Api4 */ class Note extends Generic\DAOEntity { diff --git a/Civi/Api4/OpenID.php b/Civi/Api4/OpenID.php index c316e3f915..c9c56472f7 100644 --- a/Civi/Api4/OpenID.php +++ b/Civi/Api4/OpenID.php @@ -22,6 +22,7 @@ namespace Civi\Api4; /** * OpenID entity. * + * @searchable secondary * @package Civi\Api4 */ class OpenID extends Generic\DAOEntity { diff --git a/Civi/Api4/PCPBlock.php b/Civi/Api4/PCPBlock.php index 9fe55c0eb3..0e7532a26e 100644 --- a/Civi/Api4/PCPBlock.php +++ b/Civi/Api4/PCPBlock.php @@ -21,6 +21,7 @@ namespace Civi\Api4; /** * PCP Block entity. * + * @searchable secondary * @package Civi\Api4 */ class PCPBlock extends Generic\DAOEntity { diff --git a/Civi/Api4/Participant.php b/Civi/Api4/Participant.php index 221ea1f677..9658035310 100644 --- a/Civi/Api4/Participant.php +++ b/Civi/Api4/Participant.php @@ -21,6 +21,7 @@ namespace Civi\Api4; /** * Participant entity, stores the participation record of a contact in an event. * + * @searchable primary * @package Civi\Api4 */ class Participant extends Generic\DAOEntity { diff --git a/Civi/Api4/Permission.php b/Civi/Api4/Permission.php index 95a63bc9ea..f046cbf888 100644 --- a/Civi/Api4/Permission.php +++ b/Civi/Api4/Permission.php @@ -25,7 +25,7 @@ namespace Civi\Api4; * It may be poorly suited to recursive usage (e.g. permissions defined dynamically * on top of permissions!) or during install/uninstall processes. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class Permission extends Generic\AbstractEntity { diff --git a/Civi/Api4/Phone.php b/Civi/Api4/Phone.php index 64760a8085..38e8575550 100644 --- a/Civi/Api4/Phone.php +++ b/Civi/Api4/Phone.php @@ -26,6 +26,7 @@ namespace Civi\Api4; * * Creating a new phone of a contact, requires at minimum a contact's ID and phone number * + * @searchable secondary * @package Civi\Api4 */ class Phone extends Generic\DAOEntity { diff --git a/Civi/Api4/PledgePayment.php b/Civi/Api4/PledgePayment.php index 0ece2ddc62..daa7ffad83 100644 --- a/Civi/Api4/PledgePayment.php +++ b/Civi/Api4/PledgePayment.php @@ -22,6 +22,7 @@ namespace Civi\Api4; /** * PledgePayment entity. * + * @searchable secondary * @package Civi\Api4 */ class PledgePayment extends Generic\DAOEntity { diff --git a/Civi/Api4/PriceField.php b/Civi/Api4/PriceField.php index 66aaa4428a..341a70bbf6 100644 --- a/Civi/Api4/PriceField.php +++ b/Civi/Api4/PriceField.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * PriceField entity. * + * @searchable secondary * @package Civi\Api4 */ class PriceField extends Generic\DAOEntity { diff --git a/Civi/Api4/PriceFieldValue.php b/Civi/Api4/PriceFieldValue.php index 851abbcf6e..d9bb5f578b 100644 --- a/Civi/Api4/PriceFieldValue.php +++ b/Civi/Api4/PriceFieldValue.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * PriceFieldValue entity. * + * @searchable secondary * @package Civi\Api4 */ class PriceFieldValue extends Generic\DAOEntity { diff --git a/Civi/Api4/PriceSet.php b/Civi/Api4/PriceSet.php index 91a7e27d91..df178613ca 100644 --- a/Civi/Api4/PriceSet.php +++ b/Civi/Api4/PriceSet.php @@ -15,6 +15,7 @@ namespace Civi\Api4; /** * PriceSet entity. * + * @searchable secondary * @package Civi\Api4 */ class PriceSet extends Generic\DAOEntity { diff --git a/Civi/Api4/Relationship.php b/Civi/Api4/Relationship.php index 276da78074..cc5a55c5c7 100644 --- a/Civi/Api4/Relationship.php +++ b/Civi/Api4/Relationship.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * Relationship entity. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/relationships/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class Relationship extends Generic\DAOEntity { diff --git a/Civi/Api4/Route.php b/Civi/Api4/Route.php index b6b095bf10..f40444037c 100644 --- a/Civi/Api4/Route.php +++ b/Civi/Api4/Route.php @@ -26,7 +26,7 @@ namespace Civi\Api4; * Note: this is a read-only api as routes are set via xml files and hooks. * * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterMenu/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class Route extends \Civi\Api4\Generic\AbstractEntity { diff --git a/Civi/Api4/SavedSearch.php b/Civi/Api4/SavedSearch.php index 79c5e0c2e9..26a8994645 100644 --- a/Civi/Api4/SavedSearch.php +++ b/Civi/Api4/SavedSearch.php @@ -25,7 +25,7 @@ namespace Civi\Api4; * Stores search parameters for populating smart groups with live results. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/smart-groups/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class SavedSearch extends Generic\DAOEntity { diff --git a/Civi/Api4/Setting.php b/Civi/Api4/Setting.php index f97627b6aa..a41baa6180 100644 --- a/Civi/Api4/Setting.php +++ b/Civi/Api4/Setting.php @@ -25,7 +25,7 @@ namespace Civi\Api4; * Used to read/write persistent setting data from CiviCRM. * * @see \Civi\Core\SettingsBag - * @searchable false + * @searchable none * @package Civi\Api4 */ class Setting extends Generic\AbstractEntity { diff --git a/Civi/Api4/StatusPreference.php b/Civi/Api4/StatusPreference.php index 4a2ece25dd..e3b01c5d7c 100644 --- a/Civi/Api4/StatusPreference.php +++ b/Civi/Api4/StatusPreference.php @@ -24,7 +24,7 @@ namespace Civi\Api4; * * For setting "hush" preferences for system check alerts. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class StatusPreference extends Generic\DAOEntity { diff --git a/Civi/Api4/System.php b/Civi/Api4/System.php index 9ba22ab58f..1f1f4d4b5d 100644 --- a/Civi/Api4/System.php +++ b/Civi/Api4/System.php @@ -21,6 +21,7 @@ namespace Civi\Api4; /** * A collection of system maintenance/diagnostic utilities. * + * @searchable none * @package Civi\Api4 */ class System extends Generic\AbstractEntity { diff --git a/Civi/Api4/Tag.php b/Civi/Api4/Tag.php index 8cc13f1d16..57d94d74f4 100644 --- a/Civi/Api4/Tag.php +++ b/Civi/Api4/Tag.php @@ -26,6 +26,7 @@ namespace Civi\Api4; * They are connected to those entities via the EntityTag table. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/groups-and-tags/#tags + * @searchable secondary * @package Civi\Api4 */ class Tag extends Generic\DAOEntity { diff --git a/Civi/Api4/UFField.php b/Civi/Api4/UFField.php index 6d044da207..0de725af34 100644 --- a/Civi/Api4/UFField.php +++ b/Civi/Api4/UFField.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * UFField entity - aka profile fields. * * @see \Civi\Api4\UFGroup - * @searchable false + * @searchable none * @package Civi\Api4 */ class UFField extends Generic\DAOEntity { diff --git a/Civi/Api4/UFGroup.php b/Civi/Api4/UFGroup.php index 2f80638a07..3f82f12f76 100644 --- a/Civi/Api4/UFGroup.php +++ b/Civi/Api4/UFGroup.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * UFGroup entity - AKA profiles. * * @see https://docs.civicrm.org/user/en/latest/organising-your-data/profiles/ - * @searchable false + * @searchable none * @package Civi\Api4 */ class UFGroup extends Generic\DAOEntity { diff --git a/Civi/Api4/UFJoin.php b/Civi/Api4/UFJoin.php index b1c874a93f..e2f0b3b243 100644 --- a/Civi/Api4/UFJoin.php +++ b/Civi/Api4/UFJoin.php @@ -23,7 +23,7 @@ namespace Civi\Api4; * UFJoin entity - links profiles to the components/extensions they are used for. * * @see \Civi\Api4\UFGroup - * @searchable false + * @searchable none * @package Civi\Api4 */ class UFJoin extends Generic\DAOEntity { diff --git a/Civi/Api4/UFMatch.php b/Civi/Api4/UFMatch.php index 05cd8fa5a5..87df0cbf98 100644 --- a/Civi/Api4/UFMatch.php +++ b/Civi/Api4/UFMatch.php @@ -22,7 +22,7 @@ namespace Civi\Api4; /** * UFMatch entity - links civicrm contacts with users created externally * - * @searchable false + * @searchable none * @package Civi\Api4 */ class UFMatch extends Generic\DAOEntity { diff --git a/Civi/Api4/Utils/ReflectionUtils.php b/Civi/Api4/Utils/ReflectionUtils.php index 102b1bc40e..c48f921d0c 100644 --- a/Civi/Api4/Utils/ReflectionUtils.php +++ b/Civi/Api4/Utils/ReflectionUtils.php @@ -95,9 +95,6 @@ class ReflectionUtils { elseif ($key == 'throws' || $key == 'see') { $info[$key][] = implode(' ', $words); } - elseif ($key == 'searchable') { - $info[$key] = strtolower($words[0]) !== 'false'; - } elseif ($key == 'param' && $words) { $type = $words[0][0] !== '$' ? explode('|', array_shift($words)) : NULL; $param = rtrim(array_shift($words), '-:()/'); diff --git a/Civi/Api4/Website.php b/Civi/Api4/Website.php index f800c09b65..d155f81416 100644 --- a/Civi/Api4/Website.php +++ b/Civi/Api4/Website.php @@ -22,6 +22,7 @@ namespace Civi\Api4; /** * Website entity. * + * @searchable secondary * @package Civi\Api4 */ class Website extends Generic\DAOEntity { diff --git a/ext/afform/core/Civi/Api4/Afform.php b/ext/afform/core/Civi/Api4/Afform.php index d498937353..fb242744fb 100644 --- a/ext/afform/core/Civi/Api4/Afform.php +++ b/ext/afform/core/Civi/Api4/Afform.php @@ -16,7 +16,7 @@ use Civi\Api4\Generic\BasicBatchAction; * The `prefill` and `submit` actions are used for preparing forms and processing submissions. * * @see https://lab.civicrm.org/extensions/afform - * @searchable false + * @searchable none * @package Civi\Api4 */ class Afform extends Generic\AbstractEntity { diff --git a/ext/search_kit/Civi/Api4/SearchDisplay.php b/ext/search_kit/Civi/Api4/SearchDisplay.php index 939e74664e..3bb683ce96 100644 --- a/ext/search_kit/Civi/Api4/SearchDisplay.php +++ b/ext/search_kit/Civi/Api4/SearchDisplay.php @@ -6,7 +6,7 @@ namespace Civi\Api4; * * Provided by the Search Kit extension. * - * @searchable false + * @searchable none * @package Civi\Api4 */ class SearchDisplay extends Generic\DAOEntity { diff --git a/ext/search_kit/Civi/Search/Admin.php b/ext/search_kit/Civi/Search/Admin.php index 020c7db676..9d314a8118 100644 --- a/ext/search_kit/Civi/Search/Admin.php +++ b/ext/search_kit/Civi/Search/Admin.php @@ -82,8 +82,8 @@ class Admin { public static function getSchema() { $schema = []; $entities = \Civi\Api4\Entity::get() - ->addSelect('name', 'title', 'type', 'title_plural', 'description', 'label_field', 'icon', 'paths', 'dao', 'bridge', 'ui_join_filters') - ->addWhere('searchable', '=', TRUE) + ->addSelect('name', 'title', 'type', 'title_plural', 'description', 'label_field', 'icon', 'paths', 'dao', 'bridge', 'ui_join_filters', 'searchable') + ->addWhere('searchable', '!=', 'none') ->addOrderBy('title_plural') ->setChain([ 'get' => ['$name', 'getActions', ['where' => [['name', '=', 'get']]], ['params']], diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index c4f48446f9..43af883e71 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -156,6 +156,7 @@ class ConformanceTest extends UnitTestCase { $this->assertNotEmpty($info['title_plural']); $this->assertNotEmpty($info['type']); $this->assertNotEmpty($info['description']); + $this->assertContains($info['searchable'], ['primary', 'secondary', 'none']); // Bridge must be between exactly 2 entities if (in_array('EntityBridge', $info['type'], TRUE)) { $this->assertCount(2, $info['bridge']); -- 2.25.1