Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / migrate_plus / migrate_example_advanced / migrate_example_advanced.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for migrate_example_advanced module.
6  */
7
8 use Drupal\migrate_plus\Entity\Migration;
9
10 /**
11  * Implements hook_install().
12  *
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.
17  */
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();
24     $urls = [];
25     foreach ($source['urls'] as $url) {
26       $urls[] = 'http://' . $request->getHttpHost() . $url;
27     }
28     $source['urls'] = $urls;
29     $wine_role_xml_migration->set('source', $source);
30     $wine_role_xml_migration->save();
31   }
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();
37     $urls = [];
38     foreach ($source['urls'] as $url) {
39       $urls[] = 'http://' . $request->getHttpHost() . $url;
40     }
41     $source['urls'] = $urls;
42     $wine_role_json_migration->set('source', $source);
43     $wine_role_json_migration->save();
44   }
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();
50     $urls = [];
51     foreach ($source['urls'] as $url) {
52       $urls[] = 'http://' . $request->getHttpHost() . $url;
53     }
54     $source['urls'] = $urls;
55     $wine_variety_multi_xml_migration->set('source', $source);
56     $wine_variety_multi_xml_migration->save();
57   }
58 }