Skip to content

Commit

Permalink
Add support for provisioning targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 5, 2026
1 parent 45c4efa commit dae6ae1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
27 changes: 24 additions & 3 deletions app/plugins/Transmogrify/config/schema/tables.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"__COMMENT__": "Template for adding new table configurations to the Transmogrify mapping. Keys starting with double underscores (__) are ignored by processors and exist only for documentation.",
"__EXAMPLE_TABLE_TEMPLATE__": {
"__INSTRUCTIONS__": "Copy this object, rename the key to your logical table name (eg, 'my_items'), and adjust values. Do NOT leave this example enabled in production.",
"__INSTRUCTIONS__": "When mapping legacy type fields, call the function-based mapper (eg, &map...Type) before configuring null for the old column name. The mapper still needs the original source column value, and performNoMapping() will unset that column once it sees a null mapping. In other words, always place the null mapping for the old column after the new field’s function mapping so the mapper can read the legacy value before it is removed.",
"__INSTRUCTIONS_1__": "Copy this object, rename the key to your logical table name (eg, 'my_items'), and adjust values. Do NOT leave this example enabled in production.",
"__INSTRUCTIONS_2__": "When mapping legacy type fields, call the function-based mapper (eg, &map...Type) before configuring null for the old column name. The mapper still needs the original source column value, and performNoMapping() will unset that column once it sees a null mapping. In other words, always place the null mapping for the old column after the new field’s function mapping so the mapper can read the legacy value before it is removed.",
"__INSTRUCTIONS_3__": "Columns new to v5 (not in v4) should be omitted entirely from the configuration.",
"__INSTRUCTIONS_4__": "Columns present in v4 but dropped in v5 must be mapped to null to be unset, and these mappings must go at the end of the fieldMap list.",
"source": "cm_my_items",
"displayField": "name",
"addChangelog": true,
Expand All @@ -19,7 +21,7 @@
"preRow": "beforeInsertMyItemRow",
"postRow": "afterInsertMyItemRow",
"fieldMap": {
"id": null,
"id": "id",
"co_id": "co_id",
"name": "name",
"description": "details",
Expand Down Expand Up @@ -566,6 +568,25 @@
},
"dependencies": ["groups"]
},
"provisioning_targets": {
"source": "cm_co_provisioning_targets",
"displayField": "description",
"fieldMap": {
"plugin": "&mapProvisionerPlugin",
"provision_co_group_id": "provisioning_group_id",
"skip_org_identity_source_id": null
},
"dependencies": ["groups"]
},
"sql_provisioners": {
"source": "cm_co_sql_provisioner_targets",
"displayField": "provisioning_target_id",
"plugin": "ApiConnector",
"fieldMap": {
"co_provisioning_target_id": "provisioning_target_id"
},
"addChangelog": true
},
"group_members": {
"source": "cm_co_group_members",
"displayField": "id",
Expand Down
23 changes: 21 additions & 2 deletions app/plugins/Transmogrify/src/Lib/Traits/TypeMapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Transmogrify\Lib\Util\RawSqlQueries;
use \App\Lib\Enum\MatchStrategyEnum;
use App\Lib\Enum\MatchStrategyEnum;

/**
* Encapsulates all type mapping logic and helpers (map_type + specific wrappers).
Expand Down Expand Up @@ -306,7 +306,12 @@ protected function mapPlugin(array $row, string $suffix, string $context): ?stri
$connector = $base . 'Connector';

if ($base !== '' && in_array($connector, $available, true)) {
return $connector . '.' . $pluralTable;
if ($base !== '' && in_array($connector, $available, true)) {
$mapped = $connector . '.' . $pluralTable;
if (\Cake\Core\App::className($mapped, 'Model/Table', 'Table') !== null) {
return $mapped;
}
}
}

// No mapping found
Expand Down Expand Up @@ -346,6 +351,20 @@ protected function mapAuthenticatorPlugin(array $row): ?string
return $this->mapPlugin($row, 'Authenticator', 'Authenticator');
}

/**
* Map v4 Provisioner plugin name to v5 plugin model path.
*
* Examples:
* LdapProvisioner -> LdapConnector.LdapProvisioner
*
* @param array $row Row data containing 'plugin'
* @return string|null
*/
protected function mapProvisionerPlugin(array $row): ?string
{
return $this->mapPlugin($row, 'Provisioner', 'Provisioner');
}


/**
* Map email type to corresponding type ID
Expand Down

0 comments on commit dae6ae1

Please sign in to comment.