From 28f335993f10ecb529655209c6155542a37210d4 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Tue, 11 Nov 2025 11:36:58 +0200 Subject: [PATCH] message templates --- .../Transmogrify/config/schema/tables.json | 11 +++++ .../src/Lib/Traits/TypeMapperTrait.php | 44 ++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/app/plugins/Transmogrify/config/schema/tables.json b/app/plugins/Transmogrify/config/schema/tables.json index 74a234bc0..3da5ec51e 100644 --- a/app/plugins/Transmogrify/config/schema/tables.json +++ b/app/plugins/Transmogrify/config/schema/tables.json @@ -172,6 +172,17 @@ "type": null } }, + "message_templates": { + "source": "cm_co_message_templates", + "displayField": "description", + "fieldMap": { + "context": "&mapMessageTemplateContext", + "message_subject": "subject", + "message_body": "body_text", + "message_body_html": "body_html", + "co_message_template_id": "message_template_id" + } + }, "__NOTES__": "DATA MIGRATIONS", "authentication_events": { "source": "cm_authentication_events", diff --git a/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php b/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php index c6cfdbb33..c619bc932 100644 --- a/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php +++ b/app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php @@ -33,7 +33,6 @@ use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Transmogrify\Lib\Util\RawSqlQueries; use Cake\Utility\Inflector; -use Transmogrify\Lib\Traits\CacheTrait; /** * Encapsulates all type mapping logic and helpers (map_type + specific wrappers). @@ -69,6 +68,37 @@ trait TypeMapperTrait ]; /** + * Map MessageTemplateEnum (v4) codes to MessageTemplateContextEnum (v5) codes + * + * Keys are v4 right-hand codes, values are v5 right-hand codes. + * Left-hand names are provided as context in comments. + * + * Notes: + * - EnrollmentApprover (AP) does not exist in v5; the closest functional + * equivalent is EnrollmentHandoff (EH). + * - ExpirationNotification (XN) is not present in v5; mapped to null. + * + * @var array + */ + public const MESSAGE_TEMPLATE_CONTEXT_MAP = [ + // Authenticator + 'AU' => 'AU', + // EnrollmentApprover -> EnrollmentHandoff + 'AP' => 'EH', + // EnrollmentApproval + 'EA' => 'EA', + // EnrollmentFinalization + 'EF' => 'EF', + // EnrollmentVerification -> Verification + 'EV' => 'V', + // ExpirationNotification (not used in v5 yet) + 'XN' => null, + // Plugin + 'PL' => 'PL', + ]; + + + /** * Map match attribute types to corresponding model names * * @var array @@ -183,6 +213,18 @@ protected function mapMatchAttributeTypeId(array $row): ?int return $this->mapType($row, $model . '.type', $this->findCoId($row)); } + /** + * Map v4 MessageTemplateEnum code in $row['context'] to v5 MessageTemplateContextEnum code + * + * @param array $row Row data containing 'context' (v4 record) + * @return string|null Mapped v5 context code or null if not mapped + * @since COmanage Registry v5.2.0 + */ + protected function mapMessageTemplateContext(array $row): ?string + { + return (string)self::MESSAGE_TEMPLATE_CONTEXT_MAP[$row['context']] ?? null; + } + /** * Map login identifiers, in accordance with the configuration. *