From bd3e700da5feb764d252b469965f5d10ee74145f Mon Sep 17 00:00:00 2001 From: colemanw Date: Fri, 12 May 2023 15:28:41 -0400 Subject: [PATCH 1/2] Apiv4 - Move component api files to component extensions This moves the code belonging to components into their extension directories. As before, these apis will only be available if the component is enabled, but now there is no extra code needed to make that happen. --- Civi/API/Request.php | 7 +------ Civi/Api4/Action/Entity/Get.php | 8 ++------ .../civi_campaign/Civi}/Api4/Action/Campaign/Get.php | 0 {Civi => ext/civi_campaign/Civi}/Api4/Campaign.php | 0 .../Spec/Provider/CampaignCreationSpecProvider.php | 0 {Civi => ext/civi_campaign/Civi}/Api4/Survey.php | 0 ext/civi_campaign/info.xml | 3 +++ .../Civi}/Api4/Action/CiviCase/CiviCaseSaveTrait.php | 0 .../civi_case/Civi}/Api4/Action/CiviCase/Create.php | 0 .../civi_case/Civi}/Api4/Action/CiviCase/Save.php | 0 .../civi_case/Civi}/Api4/Action/CiviCase/Update.php | 0 {Civi => ext/civi_case/Civi}/Api4/CaseActivity.php | 0 {Civi => ext/civi_case/Civi}/Api4/CaseContact.php | 0 {Civi => ext/civi_case/Civi}/Api4/CaseType.php | 0 {Civi => ext/civi_case/Civi}/Api4/CiviCase.php | 0 .../Service/Spec/Provider/CaseCreationSpecProvider.php | 0 .../Service/Spec/Provider/CaseTypeGetSpecProvider.php | 0 ext/civi_case/info.xml | 3 +++ .../Api4/Action/Contribution/ContributionSaveTrait.php | 0 .../Civi}/Api4/Action/Contribution/Create.php | 0 .../Civi}/Api4/Action/Contribution/Save.php | 0 .../Civi}/Api4/Action/Contribution/Update.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/Contribution.php | 0 .../civi_contribute/Civi}/Api4/ContributionPage.php | 0 .../civi_contribute/Civi}/Api4/ContributionProduct.php | 0 .../civi_contribute/Civi}/Api4/ContributionRecur.php | 0 .../civi_contribute/Civi}/Api4/ContributionSoft.php | 0 .../civi_contribute/Civi}/Api4/EntityFinancialAccount.php | 0 .../civi_contribute/Civi}/Api4/EntityFinancialTrxn.php | 0 .../civi_contribute/Civi}/Api4/FinancialAccount.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/FinancialItem.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/FinancialTrxn.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/FinancialType.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/LineItem.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/PCP.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/PCPBlock.php | 0 .../civi_contribute/Civi}/Api4/PaymentProcessor.php | 0 .../civi_contribute/Civi}/Api4/PaymentProcessorType.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/PaymentToken.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/PriceField.php | 0 .../civi_contribute/Civi}/Api4/PriceFieldValue.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/PriceSet.php | 0 .../civi_contribute/Civi}/Api4/PriceSetEntity.php | 0 {Civi => ext/civi_contribute/Civi}/Api4/Product.php | 0 .../Spec/Provider/ContributionCreationSpecProvider.php | 0 .../Service/Spec/Provider/ContributionGetSpecProvider.php | 0 .../Provider/ContributionRecurCreationSpecProvider.php | 0 .../Spec/Provider/FinancialItemCreationSpecProvider.php | 0 .../Spec/Provider/FinancialTrxnCreationSpecProvider.php | 0 .../Provider/PaymentProcessorCreationSpecProvider.php | 0 .../Provider/PaymentProcessorTypeCreationSpecProvider.php | 0 .../Spec/Provider/PriceFieldValueCreationSpecProvider.php | 0 ext/civi_contribute/info.xml | 3 +++ {Civi => ext/civi_event/Civi}/Api4/Action/Event/Get.php | 0 {Civi => ext/civi_event/Civi}/Api4/Event.php | 0 {Civi => ext/civi_event/Civi}/Api4/Participant.php | 0 .../civi_event/Civi}/Api4/ParticipantStatusType.php | 0 .../Service/Spec/Provider/EventCreationSpecProvider.php | 0 ext/civi_event/info.xml | 3 +++ .../Civi}/Api4/Action/MailSettings/TestConnection.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailSettings.php | 0 {Civi => ext/civi_mail/Civi}/Api4/Mailing.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingEventBounce.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingEventConfirm.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingEventOpened.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingEventQueue.php | 0 .../civi_mail/Civi}/Api4/MailingEventSubscribe.php | 0 .../civi_mail/Civi}/Api4/MailingEventTrackableURLOpen.php | 0 .../civi_mail/Civi}/Api4/MailingEventUnsubscribe.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingGroup.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingJob.php | 0 {Civi => ext/civi_mail/Civi}/Api4/MailingTrackableURL.php | 0 ext/civi_mail/info.xml | 3 +++ {Civi => ext/civi_member/Civi}/Api4/Membership.php | 0 {Civi => ext/civi_member/Civi}/Api4/MembershipBlock.php | 0 {Civi => ext/civi_member/Civi}/Api4/MembershipStatus.php | 0 {Civi => ext/civi_member/Civi}/Api4/MembershipType.php | 0 .../Spec/Provider/MembershipCreationSpecProvider.php | 0 .../Spec/Provider/MembershipTypeCreationSpecProvider.php | 0 ext/civi_member/info.xml | 3 +++ {Civi => ext/civi_pledge/Civi}/Api4/Pledge.php | 0 {Civi => ext/civi_pledge/Civi}/Api4/PledgePayment.php | 0 ext/civi_pledge/info.xml | 3 +++ {Civi => ext/civi_report/Civi}/Api4/ReportInstance.php | 0 ext/civi_report/info.xml | 3 +++ tests/phpunit/api/v4/Entity/EntityTest.php | 3 --- 86 files changed, 27 insertions(+), 15 deletions(-) rename {Civi => ext/civi_campaign/Civi}/Api4/Action/Campaign/Get.php (100%) rename {Civi => ext/civi_campaign/Civi}/Api4/Campaign.php (100%) rename {Civi => ext/civi_campaign/Civi}/Api4/Service/Spec/Provider/CampaignCreationSpecProvider.php (100%) rename {Civi => ext/civi_campaign/Civi}/Api4/Survey.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/Action/CiviCase/CiviCaseSaveTrait.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/Action/CiviCase/Create.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/Action/CiviCase/Save.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/Action/CiviCase/Update.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/CaseActivity.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/CaseContact.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/CaseType.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/CiviCase.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/Service/Spec/Provider/CaseCreationSpecProvider.php (100%) rename {Civi => ext/civi_case/Civi}/Api4/Service/Spec/Provider/CaseTypeGetSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Action/Contribution/ContributionSaveTrait.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Action/Contribution/Create.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Action/Contribution/Save.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Action/Contribution/Update.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Contribution.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/ContributionPage.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/ContributionProduct.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/ContributionRecur.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/ContributionSoft.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/EntityFinancialAccount.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/EntityFinancialTrxn.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/FinancialAccount.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/FinancialItem.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/FinancialTrxn.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/FinancialType.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/LineItem.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PCP.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PCPBlock.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PaymentProcessor.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PaymentProcessorType.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PaymentToken.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PriceField.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PriceFieldValue.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PriceSet.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/PriceSetEntity.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Product.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/ContributionCreationSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/ContributionGetSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/ContributionRecurCreationSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/FinancialItemCreationSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/FinancialTrxnCreationSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/PaymentProcessorTypeCreationSpecProvider.php (100%) rename {Civi => ext/civi_contribute/Civi}/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php (100%) rename {Civi => ext/civi_event/Civi}/Api4/Action/Event/Get.php (100%) rename {Civi => ext/civi_event/Civi}/Api4/Event.php (100%) rename {Civi => ext/civi_event/Civi}/Api4/Participant.php (100%) rename {Civi => ext/civi_event/Civi}/Api4/ParticipantStatusType.php (100%) rename {Civi => ext/civi_event/Civi}/Api4/Service/Spec/Provider/EventCreationSpecProvider.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/Action/MailSettings/TestConnection.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailSettings.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/Mailing.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventBounce.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventConfirm.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventOpened.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventQueue.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventSubscribe.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventTrackableURLOpen.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingEventUnsubscribe.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingGroup.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingJob.php (100%) rename {Civi => ext/civi_mail/Civi}/Api4/MailingTrackableURL.php (100%) rename {Civi => ext/civi_member/Civi}/Api4/Membership.php (100%) rename {Civi => ext/civi_member/Civi}/Api4/MembershipBlock.php (100%) rename {Civi => ext/civi_member/Civi}/Api4/MembershipStatus.php (100%) rename {Civi => ext/civi_member/Civi}/Api4/MembershipType.php (100%) rename {Civi => ext/civi_member/Civi}/Api4/Service/Spec/Provider/MembershipCreationSpecProvider.php (100%) rename {Civi => ext/civi_member/Civi}/Api4/Service/Spec/Provider/MembershipTypeCreationSpecProvider.php (100%) rename {Civi => ext/civi_pledge/Civi}/Api4/Pledge.php (100%) rename {Civi => ext/civi_pledge/Civi}/Api4/PledgePayment.php (100%) rename {Civi => ext/civi_report/Civi}/Api4/ReportInstance.php (100%) diff --git a/Civi/API/Request.php b/Civi/API/Request.php index 8b7a087f2ef2..c26d230a88cf 100644 --- a/Civi/API/Request.php +++ b/Civi/API/Request.php @@ -48,12 +48,7 @@ public static function create(string $entity, string $action, array $params) { $className = CoreUtil::getApiClass($entity); $callable = [$className, $action]; if (!$className || !is_callable($callable)) { - throw new \Civi\API\Exception\NotImplementedException("API ($entity, $action) does not exist (join the API team and implement it!)"); - } - // Check enabled components - $daoName = \CRM_Core_DAO_AllCoreTables::getFullName($entity); - if ($daoName && !$daoName::isComponentEnabled()) { - throw new \Civi\API\Exception\NotImplementedException("$entity API is not available because " . $daoName::COMPONENT . " component is disabled"); + throw new \Civi\API\Exception\NotImplementedException("API ($entity, $action) does not exist (or the extension it belongs to is not enabled)."); } // Extra arguments used e.g. by dynamic entities like Multi-Record custom groups & the ECK extension $args = (array) CoreUtil::getInfoItem($entity, 'class_args'); diff --git a/Civi/Api4/Action/Entity/Get.php b/Civi/Api4/Action/Entity/Get.php index d6e80485c985..3c799ca8ae63 100644 --- a/Civi/Api4/Action/Entity/Get.php +++ b/Civi/Api4/Action/Entity/Get.php @@ -15,7 +15,7 @@ /** * Get the names & docblocks of all APIv4 entities. * - * Scans for api entities in core, enabled components & enabled extensions. + * Scans for api entities in core & enabled extensions. * * Also includes pseudo-entities from multi-record custom groups. */ @@ -28,15 +28,11 @@ class Get extends \Civi\Api4\Generic\BasicGetAction { protected $includeCustom; /** - * Returns all APIv4 entities from core, enabled components and enabled extensions. + * Returns all APIv4 entities from core & enabled extensions. */ protected function getRecords() { $provider = \Civi::service('action_object_provider'); return array_filter($provider->getEntities(), function($entity) { - // Only include DAO entities from enabled components - if (!empty($entity['dao']) && !$entity['dao']::isComponentEnabled()) { - return FALSE; - } // Check custom group permissions if ($this->checkPermissions && in_array('CustomValue', $entity['type']) && !\CRM_Core_Permission::customGroupAdmin()) { // Hack to get the id from the "view" url. If that url changes tests should catch it and we'll think of a better way to get that id diff --git a/Civi/Api4/Action/Campaign/Get.php b/ext/civi_campaign/Civi/Api4/Action/Campaign/Get.php similarity index 100% rename from Civi/Api4/Action/Campaign/Get.php rename to ext/civi_campaign/Civi/Api4/Action/Campaign/Get.php diff --git a/Civi/Api4/Campaign.php b/ext/civi_campaign/Civi/Api4/Campaign.php similarity index 100% rename from Civi/Api4/Campaign.php rename to ext/civi_campaign/Civi/Api4/Campaign.php diff --git a/Civi/Api4/Service/Spec/Provider/CampaignCreationSpecProvider.php b/ext/civi_campaign/Civi/Api4/Service/Spec/Provider/CampaignCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/CampaignCreationSpecProvider.php rename to ext/civi_campaign/Civi/Api4/Service/Spec/Provider/CampaignCreationSpecProvider.php diff --git a/Civi/Api4/Survey.php b/ext/civi_campaign/Civi/Api4/Survey.php similarity index 100% rename from Civi/Api4/Survey.php rename to ext/civi_campaign/Civi/Api4/Survey.php diff --git a/ext/civi_campaign/info.xml b/ext/civi_campaign/info.xml index 477b14da4ec0..ff6b21ca2eea 100644 --- a/ext/civi_campaign/info.xml +++ b/ext/civi_campaign/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Campaign 23.02.1 diff --git a/Civi/Api4/Action/CiviCase/CiviCaseSaveTrait.php b/ext/civi_case/Civi/Api4/Action/CiviCase/CiviCaseSaveTrait.php similarity index 100% rename from Civi/Api4/Action/CiviCase/CiviCaseSaveTrait.php rename to ext/civi_case/Civi/Api4/Action/CiviCase/CiviCaseSaveTrait.php diff --git a/Civi/Api4/Action/CiviCase/Create.php b/ext/civi_case/Civi/Api4/Action/CiviCase/Create.php similarity index 100% rename from Civi/Api4/Action/CiviCase/Create.php rename to ext/civi_case/Civi/Api4/Action/CiviCase/Create.php diff --git a/Civi/Api4/Action/CiviCase/Save.php b/ext/civi_case/Civi/Api4/Action/CiviCase/Save.php similarity index 100% rename from Civi/Api4/Action/CiviCase/Save.php rename to ext/civi_case/Civi/Api4/Action/CiviCase/Save.php diff --git a/Civi/Api4/Action/CiviCase/Update.php b/ext/civi_case/Civi/Api4/Action/CiviCase/Update.php similarity index 100% rename from Civi/Api4/Action/CiviCase/Update.php rename to ext/civi_case/Civi/Api4/Action/CiviCase/Update.php diff --git a/Civi/Api4/CaseActivity.php b/ext/civi_case/Civi/Api4/CaseActivity.php similarity index 100% rename from Civi/Api4/CaseActivity.php rename to ext/civi_case/Civi/Api4/CaseActivity.php diff --git a/Civi/Api4/CaseContact.php b/ext/civi_case/Civi/Api4/CaseContact.php similarity index 100% rename from Civi/Api4/CaseContact.php rename to ext/civi_case/Civi/Api4/CaseContact.php diff --git a/Civi/Api4/CaseType.php b/ext/civi_case/Civi/Api4/CaseType.php similarity index 100% rename from Civi/Api4/CaseType.php rename to ext/civi_case/Civi/Api4/CaseType.php diff --git a/Civi/Api4/CiviCase.php b/ext/civi_case/Civi/Api4/CiviCase.php similarity index 100% rename from Civi/Api4/CiviCase.php rename to ext/civi_case/Civi/Api4/CiviCase.php diff --git a/Civi/Api4/Service/Spec/Provider/CaseCreationSpecProvider.php b/ext/civi_case/Civi/Api4/Service/Spec/Provider/CaseCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/CaseCreationSpecProvider.php rename to ext/civi_case/Civi/Api4/Service/Spec/Provider/CaseCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/CaseTypeGetSpecProvider.php b/ext/civi_case/Civi/Api4/Service/Spec/Provider/CaseTypeGetSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/CaseTypeGetSpecProvider.php rename to ext/civi_case/Civi/Api4/Service/Spec/Provider/CaseTypeGetSpecProvider.php diff --git a/ext/civi_case/info.xml b/ext/civi_case/info.xml index 794a9842c989..694c9057c079 100644 --- a/ext/civi_case/info.xml +++ b/ext/civi_case/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Case 23.02.1 diff --git a/Civi/Api4/Action/Contribution/ContributionSaveTrait.php b/ext/civi_contribute/Civi/Api4/Action/Contribution/ContributionSaveTrait.php similarity index 100% rename from Civi/Api4/Action/Contribution/ContributionSaveTrait.php rename to ext/civi_contribute/Civi/Api4/Action/Contribution/ContributionSaveTrait.php diff --git a/Civi/Api4/Action/Contribution/Create.php b/ext/civi_contribute/Civi/Api4/Action/Contribution/Create.php similarity index 100% rename from Civi/Api4/Action/Contribution/Create.php rename to ext/civi_contribute/Civi/Api4/Action/Contribution/Create.php diff --git a/Civi/Api4/Action/Contribution/Save.php b/ext/civi_contribute/Civi/Api4/Action/Contribution/Save.php similarity index 100% rename from Civi/Api4/Action/Contribution/Save.php rename to ext/civi_contribute/Civi/Api4/Action/Contribution/Save.php diff --git a/Civi/Api4/Action/Contribution/Update.php b/ext/civi_contribute/Civi/Api4/Action/Contribution/Update.php similarity index 100% rename from Civi/Api4/Action/Contribution/Update.php rename to ext/civi_contribute/Civi/Api4/Action/Contribution/Update.php diff --git a/Civi/Api4/Contribution.php b/ext/civi_contribute/Civi/Api4/Contribution.php similarity index 100% rename from Civi/Api4/Contribution.php rename to ext/civi_contribute/Civi/Api4/Contribution.php diff --git a/Civi/Api4/ContributionPage.php b/ext/civi_contribute/Civi/Api4/ContributionPage.php similarity index 100% rename from Civi/Api4/ContributionPage.php rename to ext/civi_contribute/Civi/Api4/ContributionPage.php diff --git a/Civi/Api4/ContributionProduct.php b/ext/civi_contribute/Civi/Api4/ContributionProduct.php similarity index 100% rename from Civi/Api4/ContributionProduct.php rename to ext/civi_contribute/Civi/Api4/ContributionProduct.php diff --git a/Civi/Api4/ContributionRecur.php b/ext/civi_contribute/Civi/Api4/ContributionRecur.php similarity index 100% rename from Civi/Api4/ContributionRecur.php rename to ext/civi_contribute/Civi/Api4/ContributionRecur.php diff --git a/Civi/Api4/ContributionSoft.php b/ext/civi_contribute/Civi/Api4/ContributionSoft.php similarity index 100% rename from Civi/Api4/ContributionSoft.php rename to ext/civi_contribute/Civi/Api4/ContributionSoft.php diff --git a/Civi/Api4/EntityFinancialAccount.php b/ext/civi_contribute/Civi/Api4/EntityFinancialAccount.php similarity index 100% rename from Civi/Api4/EntityFinancialAccount.php rename to ext/civi_contribute/Civi/Api4/EntityFinancialAccount.php diff --git a/Civi/Api4/EntityFinancialTrxn.php b/ext/civi_contribute/Civi/Api4/EntityFinancialTrxn.php similarity index 100% rename from Civi/Api4/EntityFinancialTrxn.php rename to ext/civi_contribute/Civi/Api4/EntityFinancialTrxn.php diff --git a/Civi/Api4/FinancialAccount.php b/ext/civi_contribute/Civi/Api4/FinancialAccount.php similarity index 100% rename from Civi/Api4/FinancialAccount.php rename to ext/civi_contribute/Civi/Api4/FinancialAccount.php diff --git a/Civi/Api4/FinancialItem.php b/ext/civi_contribute/Civi/Api4/FinancialItem.php similarity index 100% rename from Civi/Api4/FinancialItem.php rename to ext/civi_contribute/Civi/Api4/FinancialItem.php diff --git a/Civi/Api4/FinancialTrxn.php b/ext/civi_contribute/Civi/Api4/FinancialTrxn.php similarity index 100% rename from Civi/Api4/FinancialTrxn.php rename to ext/civi_contribute/Civi/Api4/FinancialTrxn.php diff --git a/Civi/Api4/FinancialType.php b/ext/civi_contribute/Civi/Api4/FinancialType.php similarity index 100% rename from Civi/Api4/FinancialType.php rename to ext/civi_contribute/Civi/Api4/FinancialType.php diff --git a/Civi/Api4/LineItem.php b/ext/civi_contribute/Civi/Api4/LineItem.php similarity index 100% rename from Civi/Api4/LineItem.php rename to ext/civi_contribute/Civi/Api4/LineItem.php diff --git a/Civi/Api4/PCP.php b/ext/civi_contribute/Civi/Api4/PCP.php similarity index 100% rename from Civi/Api4/PCP.php rename to ext/civi_contribute/Civi/Api4/PCP.php diff --git a/Civi/Api4/PCPBlock.php b/ext/civi_contribute/Civi/Api4/PCPBlock.php similarity index 100% rename from Civi/Api4/PCPBlock.php rename to ext/civi_contribute/Civi/Api4/PCPBlock.php diff --git a/Civi/Api4/PaymentProcessor.php b/ext/civi_contribute/Civi/Api4/PaymentProcessor.php similarity index 100% rename from Civi/Api4/PaymentProcessor.php rename to ext/civi_contribute/Civi/Api4/PaymentProcessor.php diff --git a/Civi/Api4/PaymentProcessorType.php b/ext/civi_contribute/Civi/Api4/PaymentProcessorType.php similarity index 100% rename from Civi/Api4/PaymentProcessorType.php rename to ext/civi_contribute/Civi/Api4/PaymentProcessorType.php diff --git a/Civi/Api4/PaymentToken.php b/ext/civi_contribute/Civi/Api4/PaymentToken.php similarity index 100% rename from Civi/Api4/PaymentToken.php rename to ext/civi_contribute/Civi/Api4/PaymentToken.php diff --git a/Civi/Api4/PriceField.php b/ext/civi_contribute/Civi/Api4/PriceField.php similarity index 100% rename from Civi/Api4/PriceField.php rename to ext/civi_contribute/Civi/Api4/PriceField.php diff --git a/Civi/Api4/PriceFieldValue.php b/ext/civi_contribute/Civi/Api4/PriceFieldValue.php similarity index 100% rename from Civi/Api4/PriceFieldValue.php rename to ext/civi_contribute/Civi/Api4/PriceFieldValue.php diff --git a/Civi/Api4/PriceSet.php b/ext/civi_contribute/Civi/Api4/PriceSet.php similarity index 100% rename from Civi/Api4/PriceSet.php rename to ext/civi_contribute/Civi/Api4/PriceSet.php diff --git a/Civi/Api4/PriceSetEntity.php b/ext/civi_contribute/Civi/Api4/PriceSetEntity.php similarity index 100% rename from Civi/Api4/PriceSetEntity.php rename to ext/civi_contribute/Civi/Api4/PriceSetEntity.php diff --git a/Civi/Api4/Product.php b/ext/civi_contribute/Civi/Api4/Product.php similarity index 100% rename from Civi/Api4/Product.php rename to ext/civi_contribute/Civi/Api4/Product.php diff --git a/Civi/Api4/Service/Spec/Provider/ContributionCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/ContributionCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/ContributionCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/ContributionCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/ContributionGetSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/ContributionGetSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/ContributionGetSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/ContributionGetSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/ContributionRecurCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/ContributionRecurCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/ContributionRecurCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/ContributionRecurCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/FinancialItemCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/FinancialItemCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/FinancialItemCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/FinancialItemCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/FinancialTrxnCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/FinancialTrxnCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/FinancialTrxnCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/FinancialTrxnCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/PaymentProcessorCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/PaymentProcessorTypeCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/PaymentProcessorTypeCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/PaymentProcessorTypeCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/PaymentProcessorTypeCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php b/ext/civi_contribute/Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php rename to ext/civi_contribute/Civi/Api4/Service/Spec/Provider/PriceFieldValueCreationSpecProvider.php diff --git a/ext/civi_contribute/info.xml b/ext/civi_contribute/info.xml index a1bf60c36221..094a59d3486f 100644 --- a/ext/civi_contribute/info.xml +++ b/ext/civi_contribute/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Contribute 23.02.1 diff --git a/Civi/Api4/Action/Event/Get.php b/ext/civi_event/Civi/Api4/Action/Event/Get.php similarity index 100% rename from Civi/Api4/Action/Event/Get.php rename to ext/civi_event/Civi/Api4/Action/Event/Get.php diff --git a/Civi/Api4/Event.php b/ext/civi_event/Civi/Api4/Event.php similarity index 100% rename from Civi/Api4/Event.php rename to ext/civi_event/Civi/Api4/Event.php diff --git a/Civi/Api4/Participant.php b/ext/civi_event/Civi/Api4/Participant.php similarity index 100% rename from Civi/Api4/Participant.php rename to ext/civi_event/Civi/Api4/Participant.php diff --git a/Civi/Api4/ParticipantStatusType.php b/ext/civi_event/Civi/Api4/ParticipantStatusType.php similarity index 100% rename from Civi/Api4/ParticipantStatusType.php rename to ext/civi_event/Civi/Api4/ParticipantStatusType.php diff --git a/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php b/ext/civi_event/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php rename to ext/civi_event/Civi/Api4/Service/Spec/Provider/EventCreationSpecProvider.php diff --git a/ext/civi_event/info.xml b/ext/civi_event/info.xml index 33b0e58c3c14..bfd7f159426e 100644 --- a/ext/civi_event/info.xml +++ b/ext/civi_event/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Event 23.02.1 diff --git a/Civi/Api4/Action/MailSettings/TestConnection.php b/ext/civi_mail/Civi/Api4/Action/MailSettings/TestConnection.php similarity index 100% rename from Civi/Api4/Action/MailSettings/TestConnection.php rename to ext/civi_mail/Civi/Api4/Action/MailSettings/TestConnection.php diff --git a/Civi/Api4/MailSettings.php b/ext/civi_mail/Civi/Api4/MailSettings.php similarity index 100% rename from Civi/Api4/MailSettings.php rename to ext/civi_mail/Civi/Api4/MailSettings.php diff --git a/Civi/Api4/Mailing.php b/ext/civi_mail/Civi/Api4/Mailing.php similarity index 100% rename from Civi/Api4/Mailing.php rename to ext/civi_mail/Civi/Api4/Mailing.php diff --git a/Civi/Api4/MailingEventBounce.php b/ext/civi_mail/Civi/Api4/MailingEventBounce.php similarity index 100% rename from Civi/Api4/MailingEventBounce.php rename to ext/civi_mail/Civi/Api4/MailingEventBounce.php diff --git a/Civi/Api4/MailingEventConfirm.php b/ext/civi_mail/Civi/Api4/MailingEventConfirm.php similarity index 100% rename from Civi/Api4/MailingEventConfirm.php rename to ext/civi_mail/Civi/Api4/MailingEventConfirm.php diff --git a/Civi/Api4/MailingEventOpened.php b/ext/civi_mail/Civi/Api4/MailingEventOpened.php similarity index 100% rename from Civi/Api4/MailingEventOpened.php rename to ext/civi_mail/Civi/Api4/MailingEventOpened.php diff --git a/Civi/Api4/MailingEventQueue.php b/ext/civi_mail/Civi/Api4/MailingEventQueue.php similarity index 100% rename from Civi/Api4/MailingEventQueue.php rename to ext/civi_mail/Civi/Api4/MailingEventQueue.php diff --git a/Civi/Api4/MailingEventSubscribe.php b/ext/civi_mail/Civi/Api4/MailingEventSubscribe.php similarity index 100% rename from Civi/Api4/MailingEventSubscribe.php rename to ext/civi_mail/Civi/Api4/MailingEventSubscribe.php diff --git a/Civi/Api4/MailingEventTrackableURLOpen.php b/ext/civi_mail/Civi/Api4/MailingEventTrackableURLOpen.php similarity index 100% rename from Civi/Api4/MailingEventTrackableURLOpen.php rename to ext/civi_mail/Civi/Api4/MailingEventTrackableURLOpen.php diff --git a/Civi/Api4/MailingEventUnsubscribe.php b/ext/civi_mail/Civi/Api4/MailingEventUnsubscribe.php similarity index 100% rename from Civi/Api4/MailingEventUnsubscribe.php rename to ext/civi_mail/Civi/Api4/MailingEventUnsubscribe.php diff --git a/Civi/Api4/MailingGroup.php b/ext/civi_mail/Civi/Api4/MailingGroup.php similarity index 100% rename from Civi/Api4/MailingGroup.php rename to ext/civi_mail/Civi/Api4/MailingGroup.php diff --git a/Civi/Api4/MailingJob.php b/ext/civi_mail/Civi/Api4/MailingJob.php similarity index 100% rename from Civi/Api4/MailingJob.php rename to ext/civi_mail/Civi/Api4/MailingJob.php diff --git a/Civi/Api4/MailingTrackableURL.php b/ext/civi_mail/Civi/Api4/MailingTrackableURL.php similarity index 100% rename from Civi/Api4/MailingTrackableURL.php rename to ext/civi_mail/Civi/Api4/MailingTrackableURL.php diff --git a/ext/civi_mail/info.xml b/ext/civi_mail/info.xml index 3e4c7bd27390..11d02d4f2664 100644 --- a/ext/civi_mail/info.xml +++ b/ext/civi_mail/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Mailing 23.02.1 diff --git a/Civi/Api4/Membership.php b/ext/civi_member/Civi/Api4/Membership.php similarity index 100% rename from Civi/Api4/Membership.php rename to ext/civi_member/Civi/Api4/Membership.php diff --git a/Civi/Api4/MembershipBlock.php b/ext/civi_member/Civi/Api4/MembershipBlock.php similarity index 100% rename from Civi/Api4/MembershipBlock.php rename to ext/civi_member/Civi/Api4/MembershipBlock.php diff --git a/Civi/Api4/MembershipStatus.php b/ext/civi_member/Civi/Api4/MembershipStatus.php similarity index 100% rename from Civi/Api4/MembershipStatus.php rename to ext/civi_member/Civi/Api4/MembershipStatus.php diff --git a/Civi/Api4/MembershipType.php b/ext/civi_member/Civi/Api4/MembershipType.php similarity index 100% rename from Civi/Api4/MembershipType.php rename to ext/civi_member/Civi/Api4/MembershipType.php diff --git a/Civi/Api4/Service/Spec/Provider/MembershipCreationSpecProvider.php b/ext/civi_member/Civi/Api4/Service/Spec/Provider/MembershipCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/MembershipCreationSpecProvider.php rename to ext/civi_member/Civi/Api4/Service/Spec/Provider/MembershipCreationSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/MembershipTypeCreationSpecProvider.php b/ext/civi_member/Civi/Api4/Service/Spec/Provider/MembershipTypeCreationSpecProvider.php similarity index 100% rename from Civi/Api4/Service/Spec/Provider/MembershipTypeCreationSpecProvider.php rename to ext/civi_member/Civi/Api4/Service/Spec/Provider/MembershipTypeCreationSpecProvider.php diff --git a/ext/civi_member/info.xml b/ext/civi_member/info.xml index ee02946a0514..8b7b35754209 100644 --- a/ext/civi_member/info.xml +++ b/ext/civi_member/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Member 23.02.1 diff --git a/Civi/Api4/Pledge.php b/ext/civi_pledge/Civi/Api4/Pledge.php similarity index 100% rename from Civi/Api4/Pledge.php rename to ext/civi_pledge/Civi/Api4/Pledge.php diff --git a/Civi/Api4/PledgePayment.php b/ext/civi_pledge/Civi/Api4/PledgePayment.php similarity index 100% rename from Civi/Api4/PledgePayment.php rename to ext/civi_pledge/Civi/Api4/PledgePayment.php diff --git a/ext/civi_pledge/info.xml b/ext/civi_pledge/info.xml index f60fcd6d18e0..e49c880c3066 100644 --- a/ext/civi_pledge/info.xml +++ b/ext/civi_pledge/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Pledge 23.02.1 diff --git a/Civi/Api4/ReportInstance.php b/ext/civi_report/Civi/Api4/ReportInstance.php similarity index 100% rename from Civi/Api4/ReportInstance.php rename to ext/civi_report/Civi/Api4/ReportInstance.php diff --git a/ext/civi_report/info.xml b/ext/civi_report/info.xml index c2fb39c3c25f..d8179e344608 100644 --- a/ext/civi_report/info.xml +++ b/ext/civi_report/info.xml @@ -24,6 +24,9 @@ + + scan-classes@1.0.0 + CRM/Report 23.02.1 diff --git a/tests/phpunit/api/v4/Entity/EntityTest.php b/tests/phpunit/api/v4/Entity/EntityTest.php index 0d7c437a4e82..904a1454e8cb 100644 --- a/tests/phpunit/api/v4/Entity/EntityTest.php +++ b/tests/phpunit/api/v4/Entity/EntityTest.php @@ -29,14 +29,11 @@ class EntityTest extends Api4TestBase { public function testEntityGet() { - \CRM_Core_BAO_ConfigSetting::enableComponent('CiviEvent'); $result = Entity::get(FALSE) ->execute() ->indexBy('name'); $this->assertArrayHasKey('Entity', $result, "Entity::get missing itself"); - $this->assertArrayHasKey('Participant', $result, - "Entity::get missing Participant"); $this->assertEquals('CRM_Contact_DAO_Contact', $result['Contact']['dao']); $this->assertEquals(['DAOEntity'], $result['Contact']['type']); From 6998c192dbdd72bb4a144aa8652cd4c107a70a6f Mon Sep 17 00:00:00 2001 From: colemanw Date: Mon, 15 May 2023 13:09:08 -0400 Subject: [PATCH 2/2] Apiv4 - Test fixes after moving component api files to extensions --- .../phpunit/api/v4/Entity/ConformanceTest.php | 22 +++++++++---------- tests/phpunit/api/v4/Entity/EntityTest.php | 10 --------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index 38932ace7501..f33baccef562 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -85,10 +85,6 @@ public function tearDown(): void { * @throws \CRM_Core_Exception */ public function getEntitiesHitech(): array { - // Ensure all components are enabled so their entities show up - foreach (array_keys(\CRM_Core_Component::getComponents()) as $component) { - \CRM_Core_BAO_ConfigSetting::enableComponent($component); - } return $this->toDataProviderArray(Entity::get(FALSE)->execute()->column('name')); } @@ -102,20 +98,22 @@ public function getEntitiesHitech(): array { * @return array */ public function getEntitiesLotech(): array { - // TODO: Auto-scan required core extensions like search_kit - $manual['add'] = ['SearchDisplay', 'SearchSegment']; - $manual['remove'] = ['CustomValue']; + // Core + required core extensions + $directores = ['', 'ext/search_kit/', 'ext/civi_*/']; + $manual['remove'] = ['CustomValue', 'SKEntity']; $manual['transform'] = ['CiviCase' => 'Case']; $scanned = []; - $srcDir = dirname(__DIR__, 5); - foreach ((array) glob("$srcDir/Civi/Api4/*.php") as $name) { - $fileName = basename($name, '.php'); - $scanned[] = $manual['transform'][$fileName] ?? $fileName; + $baseDir = dirname(__DIR__, 5); + foreach ($directores as $directory) { + foreach ((array) glob("$baseDir/{$directory}Civi/Api4/*.php") as $name) { + $fileName = basename($name, '.php'); + $scanned[] = $manual['transform'][$fileName] ?? $fileName; + } } $names = array_diff( - array_unique(array_merge($scanned, $manual['add'])), + $scanned, $manual['remove'] ); diff --git a/tests/phpunit/api/v4/Entity/EntityTest.php b/tests/phpunit/api/v4/Entity/EntityTest.php index 904a1454e8cb..271e94cfcaab 100644 --- a/tests/phpunit/api/v4/Entity/EntityTest.php +++ b/tests/phpunit/api/v4/Entity/EntityTest.php @@ -19,7 +19,6 @@ namespace api\v4\Entity; -use Civi\API\Exception\NotImplementedException; use Civi\Api4\Entity; use api\v4\Api4TestBase; @@ -60,15 +59,6 @@ public function testEntityComponent() { $this->assertArrayNotHasKey('Participant', $result, "Entity::get should not have Participant when CiviEvent disabled"); - // Trying to use a CiviEvent API will fail when component is disabled - try { - \Civi\Api4\Participant::get(FALSE)->execute(); - $this->fail(); - } - catch (NotImplementedException $e) { - $this->assertStringContainsString('CiviEvent', $e->getMessage()); - } - \CRM_Core_BAO_ConfigSetting::enableComponent('CiviEvent'); $result = Entity::get(FALSE) ->execute()