From c281bce4431d23dc572d1dfe71b3ae149e3fd3bf Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 25 Jul 2023 16:18:51 +1200 Subject: [PATCH] Fix Import Template path to be dynamic, depending on the entity --- .../Spec/Provider/UserJobSpecProvider.php | 39 +++++++++++++++++++ Civi/Api4/Utils/FormattingUtil.php | 2 +- .../Managed/UserJobSearches.mgd.php | 4 +- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 Civi/Api4/Service/Spec/Provider/UserJobSpecProvider.php diff --git a/Civi/Api4/Service/Spec/Provider/UserJobSpecProvider.php b/Civi/Api4/Service/Spec/Provider/UserJobSpecProvider.php new file mode 100644 index 0000000000..e15274f755 --- /dev/null +++ b/Civi/Api4/Service/Spec/Provider/UserJobSpecProvider.php @@ -0,0 +1,39 @@ +getFieldByName('job_type') + ->setSuffixes(['name', 'label', 'url']); + } + + /** + * @inheritDoc + */ + public function applies($entity, $action): bool { + return $entity === 'UserJob'; + } + +} diff --git a/Civi/Api4/Utils/FormattingUtil.php b/Civi/Api4/Utils/FormattingUtil.php index 380a7afc94..9498079c3f 100644 --- a/Civi/Api4/Utils/FormattingUtil.php +++ b/Civi/Api4/Utils/FormattingUtil.php @@ -30,7 +30,7 @@ class FormattingUtil { /** * @var string[] */ - public static $pseudoConstantSuffixes = ['name', 'abbr', 'label', 'color', 'description', 'icon', 'grouping']; + public static $pseudoConstantSuffixes = ['name', 'abbr', 'label', 'color', 'description', 'icon', 'grouping', 'url']; /** * Massage values into the format the BAO expects for a write operation diff --git a/ext/civiimport/Managed/UserJobSearches.mgd.php b/ext/civiimport/Managed/UserJobSearches.mgd.php index bf676b082c..22747d494e 100644 --- a/ext/civiimport/Managed/UserJobSearches.mgd.php +++ b/ext/civiimport/Managed/UserJobSearches.mgd.php @@ -138,7 +138,7 @@ return [ 'label' => E::ts('Import Name'), 'sortable' => TRUE, 'link' => [ - 'path' => 'civicrm/import/contribution?reset=1&template_id=[id]', + 'path' => '[job_type:url]?reset=1&template_id=[id]', 'entity' => '', 'action' => '', 'join' => '', @@ -264,7 +264,7 @@ return [ 'label' => E::ts('Import Name'), 'sortable' => TRUE, 'link' => [ - 'path' => 'civicrm/import/contribution?reset=1&template_id=[id]', + 'path' => '[job_type:url]?reset=1&template_id=[id]', 'entity' => '', 'action' => '', 'join' => '', -- 2.25.1