Mercurial > hg > isophonics-drupal-site
comparison core/modules/migrate_drupal/src/MigrationConfigurationTrait.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 1fec387a4317 |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
9 | 9 |
10 /** | 10 /** |
11 * Configures the appropriate migrations for a given source Drupal database. | 11 * Configures the appropriate migrations for a given source Drupal database. |
12 */ | 12 */ |
13 trait MigrationConfigurationTrait { | 13 trait MigrationConfigurationTrait { |
14 | |
15 /** | |
16 * The follow-up migration tags. | |
17 * | |
18 * @var string[] | |
19 */ | |
20 protected $followUpMigrationTags; | |
14 | 21 |
15 /** | 22 /** |
16 * Gets the database connection for the source Drupal database. | 23 * Gets the database connection for the source Drupal database. |
17 * | 24 * |
18 * @param array $database | 25 * @param array $database |
94 $plugin_manager = \Drupal::service('plugin.manager.migration'); | 101 $plugin_manager = \Drupal::service('plugin.manager.migration'); |
95 /** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */ | 102 /** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */ |
96 $all_migrations = $plugin_manager->createInstancesByTag($version_tag); | 103 $all_migrations = $plugin_manager->createInstancesByTag($version_tag); |
97 $migrations = []; | 104 $migrations = []; |
98 foreach ($all_migrations as $migration) { | 105 foreach ($all_migrations as $migration) { |
106 // Skip migrations tagged with any of the follow-up migration tags. They | |
107 // will be derived and executed after the migrations on which they depend | |
108 // have been successfully executed. | |
109 // @see Drupal\migrate_drupal\Plugin\MigrationWithFollowUpInterface | |
110 if (!empty(array_intersect($migration->getMigrationTags(), $this->getFollowUpMigrationTags()))) { | |
111 continue; | |
112 } | |
99 try { | 113 try { |
100 // @todo https://drupal.org/node/2681867 We should be able to validate | 114 // @todo https://drupal.org/node/2681867 We should be able to validate |
101 // the entire migration at this point. | 115 // the entire migration at this point. |
102 $source_plugin = $migration->getSourcePlugin(); | 116 $source_plugin = $migration->getSourcePlugin(); |
103 if ($source_plugin instanceof RequirementsInterface) { | 117 if ($source_plugin instanceof RequirementsInterface) { |
115 // ignored. | 129 // ignored. |
116 } | 130 } |
117 } | 131 } |
118 | 132 |
119 return $migrations; | 133 return $migrations; |
134 } | |
135 | |
136 /** | |
137 * Returns the follow-up migration tags. | |
138 * | |
139 * @return string[] | |
140 */ | |
141 protected function getFollowUpMigrationTags() { | |
142 if ($this->followUpMigrationTags === NULL) { | |
143 $this->followUpMigrationTags = \Drupal::configFactory() | |
144 ->get('migrate_drupal.settings') | |
145 ->get('follow_up_migration_tags') ?: []; | |
146 } | |
147 return $this->followUpMigrationTags; | |
120 } | 148 } |
121 | 149 |
122 /** | 150 /** |
123 * Determines what version of Drupal the source database contains. | 151 * Determines what version of Drupal the source database contains. |
124 * | 152 * |