From 223671d07ef1d1a607ef283f1fe424ad040eb5df Mon Sep 17 00:00:00 2001 From: Eileen McNaughton <emcnaughton@wikimedia.org> Date: Fri, 3 Sep 2021 11:34:45 +1200 Subject: [PATCH] dev/core#2486 Add survey v4 api --- CRM/Campaign/DAO/Survey.php | 9 +++++++- Civi/Api4/Survey.php | 23 +++++++++++++++++++ .../phpunit/api/v3/SyntaxConformanceTest.php | 2 ++ xml/schema/Campaign/Survey.xml | 7 ++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Civi/Api4/Survey.php diff --git a/CRM/Campaign/DAO/Survey.php b/CRM/Campaign/DAO/Survey.php index b46e6235c0b..bc051c862cd 100644 --- a/CRM/Campaign/DAO/Survey.php +++ b/CRM/Campaign/DAO/Survey.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Campaign/Survey.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:45c10db72afe877c41ddb78b79153648) + * (GenCodeChecksum:8fec5a0ffb4667af4f00820de74aa577) */ /** @@ -474,6 +474,13 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO { 'entity' => 'Survey', 'bao' => 'CRM_Campaign_BAO_Survey', 'localizable' => 0, + 'pseudoconstant' => [ + 'table' => 'civicrm_option_group', + 'keyColumn' => 'id', + 'labelColumn' => 'title', + 'nameColumn' => 'name', + 'condition' => 'name LIKE "civicrm_survey_%"', + ], 'add' => '3.3', ], 'bypass_confirm' => [ diff --git a/Civi/Api4/Survey.php b/Civi/Api4/Survey.php new file mode 100644 index 00000000000..c4cb0d433f5 --- /dev/null +++ b/Civi/Api4/Survey.php @@ -0,0 +1,23 @@ +<?php +/* + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC. All rights reserved. | + | | + | This work is published under the GNU AGPLv3 license with some | + | permitted exceptions and without any warranty. For full license | + | and copyright information, see https://civicrm.org/licensing | + +--------------------------------------------------------------------+ + */ +namespace Civi\Api4; + +/** + * Survey entity. + * + * @see https://docs.civicrm.org/user/en/latest/survey/what-is-civisurvey/ + * @searchable secondary + * @since 5.43 + * @package Civi\Api4 + */ +class Survey extends Generic\DAOEntity { + +} diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index d5917363950..b9d496bb948 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -538,6 +538,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'Logging', // Skip message template because workflow_id/workflow_name are sync'd. 'MessageTemplate', + // Skip survey because the pseudoconstant will have no options. + 'Survey', ]; if ($sequential === TRUE) { return $entitiesWithout; diff --git a/xml/schema/Campaign/Survey.xml b/xml/schema/Campaign/Survey.xml index e57a3b1f4de..0433f898b57 100644 --- a/xml/schema/Campaign/Survey.xml +++ b/xml/schema/Campaign/Survey.xml @@ -214,6 +214,13 @@ <default>NULL</default> <comment>Used to store option group id.</comment> <add>3.3</add> + <pseudoconstant> + <table>civicrm_option_group</table> + <keyColumn>id</keyColumn> + <labelColumn>title</labelColumn> + <nameColumn>name</nameColumn> + <condition>name LIKE "civicrm_survey_%"</condition> + </pseudoconstant> </field> <field> <name>bypass_confirm</name> -- GitLab