Repository navigation
Expand file tree
/
Copy pathmigrate_helper.api.php
More file actions
59 lines (53 loc) · 1.67 KB
/
Copy pathmigrate_helper.api.php
File metadata and controls
59 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* @file
* Hooks provided by the Migrate Helper module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Alter the migrate source page build array.
*
* This hook allows modules to add additional information to the migrate
* source page displayed for entities. The page shows migration mapping
* information for content that was created through migrations.
*
* @param array $build
* The render array for the migrate source page.
* @param array $context
* An associative array containing:
* - entity: The content entity being viewed.
* - entity_type: The entity type ID (e.g., 'node', 'media').
* - mappings: Array of migration mappings, each containing:
* - migration_id: The migration plugin ID.
* - source_id: Composite source ID string (colon-separated).
* - source_ids: Array of individual source ID values.
* - source_row_status: The migration row status (0=Imported, 1=Needs
* update, 2=Stub, 3=Failed).
* - last_imported: Timestamp of last import.
* - request: The current Symfony Request object.
*
* @see \Drupal\migrate_helper\Controller\MigrateSourceController::sourcePage()
*/
function hook_migrate_helper_source_page_alter(array &$build, array $context): void {
$entity = $context['entity'];
$mappings = $context['mappings'];
if (!empty($mappings)) {
$sourceId = $mappings[0]['source_ids'][0] ?? NULL;
if ($sourceId) {
$build['custom_data'] = [
'#type' => 'details',
'#title' => t('Custom Source Data'),
'#open' => TRUE,
'content' => [
'#markup' => t('Source ID: @id', ['@id' => $sourceId]),
],
];
}
}
}
/**
* @} End of "addtogroup hooks".
*/