Skip to content

Commit

Permalink
message templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Nov 11, 2025
1 parent 02e5470 commit 28f3359
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/plugins/Transmogrify/config/schema/tables.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 43 additions & 1 deletion app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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<string, string|null>
*/
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<string,string>
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 28f3359

Please sign in to comment.