5 * Install, update and uninstall functions for migrate_example_advanced module.
8 use Drupal\migrate_plus\Entity\Migration;
11 * Implements hook_install().
13 * We need the urls to be absolute for the XML source plugin to read them, but
14 * the static configuration files on disk can't know the server and port to
15 * use. So, in the .yml files we provide the REST resources relative to the
16 * site root and here rewrite them to fully-qualified paths.
18 function migrate_example_advanced_install() {
19 /** @var \Drupal\migrate_plus\Entity\MigrationInterface $wine_role_xml_migration */
20 $wine_role_xml_migration = Migration::load('wine_role_xml');
21 if ($wine_role_xml_migration) {
22 $source = $wine_role_xml_migration->get('source');
23 $request = \Drupal::request();
25 foreach ($source['urls'] as $url) {
26 $urls[] = 'http://' . $request->getHttpHost() . $url;
28 $source['urls'] = $urls;
29 $wine_role_xml_migration->set('source', $source);
30 $wine_role_xml_migration->save();
32 /** @var \Drupal\migrate_plus\Entity\MigrationInterface $wine_role_json_migration */
33 $wine_role_json_migration = Migration::load('wine_role_json');
34 if ($wine_role_json_migration) {
35 $source = $wine_role_json_migration->get('source');
36 $request = \Drupal::request();
38 foreach ($source['urls'] as $url) {
39 $urls[] = 'http://' . $request->getHttpHost() . $url;
41 $source['urls'] = $urls;
42 $wine_role_json_migration->set('source', $source);
43 $wine_role_json_migration->save();
45 /** @var \Drupal\migrate_plus\Entity\MigrationInterface $wine_variety_multi_xml_migration */
46 $wine_variety_multi_xml_migration = Migration::load('wine_variety_multi_xml');
47 if ($wine_variety_multi_xml_migration) {
48 $source = $wine_variety_multi_xml_migration->get('source');
49 $request = \Drupal::request();
51 foreach ($source['urls'] as $url) {
52 $urls[] = 'http://' . $request->getHttpHost() . $url;
54 $source['urls'] = $urls;
55 $wine_variety_multi_xml_migration->set('source', $source);
56 $wine_variety_multi_xml_migration->save();