From 03b670045daa3668713a74f0f98b81eb0c7f8dab Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 1 May 2020 20:30:08 -0400 Subject: [PATCH] APIv4 - Deprecate old way of retrieving activityType/optionValue ids --- Civi/Api4/Event/Subscriber/ActivityPreCreationSubscriber.php | 1 + .../Event/Subscriber/OptionValuePreCreationSubscriber.php | 2 +- tests/phpunit/api/v4/DataSets/ConformanceTest.json | 2 +- tests/phpunit/api/v4/DataSets/DefaultDataSet.json | 4 ++-- tests/phpunit/api/v4/DataSets/SingleContact.json | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Civi/Api4/Event/Subscriber/ActivityPreCreationSubscriber.php b/Civi/Api4/Event/Subscriber/ActivityPreCreationSubscriber.php index 95f09ac613..806a3d451e 100644 --- a/Civi/Api4/Event/Subscriber/ActivityPreCreationSubscriber.php +++ b/Civi/Api4/Event/Subscriber/ActivityPreCreationSubscriber.php @@ -34,6 +34,7 @@ class ActivityPreCreationSubscriber extends Generic\PreCreationSubscriber { protected function modify(DAOCreateAction $request) { $activityType = $request->getValue('activity_type'); if ($activityType) { + \CRM_Core_Error::deprecatedFunctionWarning('Use activity_type_id:name instead of activity_type in APIv4'); $result = OptionValue::get() ->setCheckPermissions(FALSE) ->addWhere('name', '=', $activityType) diff --git a/Civi/Api4/Event/Subscriber/OptionValuePreCreationSubscriber.php b/Civi/Api4/Event/Subscriber/OptionValuePreCreationSubscriber.php index 83140c7b9a..355738cf86 100644 --- a/Civi/Api4/Event/Subscriber/OptionValuePreCreationSubscriber.php +++ b/Civi/Api4/Event/Subscriber/OptionValuePreCreationSubscriber.php @@ -52,7 +52,7 @@ class OptionValuePreCreationSubscriber extends Generic\PreCreationSubscriber { if (!$optionGroupName || $request->getValue('option_group_id')) { return; } - + \CRM_Core_Error::deprecatedFunctionWarning('Use option_group_id:name instead of option_group in APIv4'); $optionGroup = OptionGroup::get() ->setCheckPermissions(FALSE) ->addSelect('id') diff --git a/tests/phpunit/api/v4/DataSets/ConformanceTest.json b/tests/phpunit/api/v4/DataSets/ConformanceTest.json index 1028c5b6f8..15a2a66b1d 100644 --- a/tests/phpunit/api/v4/DataSets/ConformanceTest.json +++ b/tests/phpunit/api/v4/DataSets/ConformanceTest.json @@ -35,7 +35,7 @@ "Activity": [ { "subject": "Test A Phone Activity", - "activity_type": "Phone Call", + "activity_type_id:name": "Phone Call", "source_contact_id": "@ref test_contact_1.id" } ] diff --git a/tests/phpunit/api/v4/DataSets/DefaultDataSet.json b/tests/phpunit/api/v4/DataSets/DefaultDataSet.json index 7d4a91bc77..834f107460 100644 --- a/tests/phpunit/api/v4/DataSets/DefaultDataSet.json +++ b/tests/phpunit/api/v4/DataSets/DefaultDataSet.json @@ -16,12 +16,12 @@ "Activity": [ { "subject": "Test Phone Activity", - "activity_type": "Phone Call", + "activity_type_id:name": "Phone Call", "source_contact_id": "@ref test_contact_1.id" }, { "subject": "Another Activity", - "activity_type": "Meeting", + "activity_type_id:name": "Meeting", "source_contact_id": "@ref test_contact_1.id", "assignee_contact_id": [ "@ref test_contact_1.id", diff --git a/tests/phpunit/api/v4/DataSets/SingleContact.json b/tests/phpunit/api/v4/DataSets/SingleContact.json index 73e7369e6b..41553368d6 100644 --- a/tests/phpunit/api/v4/DataSets/SingleContact.json +++ b/tests/phpunit/api/v4/DataSets/SingleContact.json @@ -11,13 +11,13 @@ "Activity": [ { "subject": "Won A Nobel Prize", - "activity_type": "Meeting", + "activity_type_id:name": "Meeting", "source_contact_id": "@ref test_contact_1.id", "@ref": "test_activity_1" }, { "subject": "Cleaned The House", - "activity_type": "Meeting", + "activity_type_id:name": "Meeting", "source_contact_id": "@ref test_contact_1.id", "assignee_contact_id": [ "@ref test_contact_1.id" -- 2.25.1