Comments

chx created an issue. See original summary.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

benjy’s picture

Title: Inject modulehandler into the migration plugins » Inject migration and source plugin managers into the migration plugins
alexpott’s picture

This is not going to be pretty because \Drupal is letting us get away with Drupal\migrate\Plugin\MigrationDeriverTrait

alexpott’s picture

Issue tags: +beta target

I don't think this needs a specific mention in the release notes

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new31.02 KB

Here's a first effort.

Status: Needs review » Needs work

The last submitted patch, 6: 2666650-6.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new2.65 KB
new30.53 KB
benjy’s picture

Nice work, I can tell this wouldn't have come together so easily.

+++ b/core/modules/migrate/src/Plugin/MigrationDeriverTrait.php
@@ -31,7 +31,7 @@ public static function getSourcePlugin($source_plugin_id) {
+    return \Drupal::service('plugin.manager.migration')->createMigrationFromCustomDefinition($definition)->getSourcePlugin();

+++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php
@@ -223,4 +223,21 @@ protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids)
+  public function createMigrationFromCustomDefinition(array $definition) {

I don't know about this going on the plugin manager, maybe we could put it in the trait until we solve the root of the issue? #2543552: Modernize migration source plugins Or, maybe we should call it createStubMigration()?

alexpott’s picture

StatusFileSize
new16.66 KB
new29.89 KB

I think it is natural that the migration plugin manager creates migrations - so why not put it there? Patch attached changes the name to your suggestion and also refactors the method to be simpler and less vulnerable to code changes.

benjy’s picture

\Drupal::keyValue('migrate:high_water');
\Drupal::keyValue('migrate_status')->set($this->id(), $status);
\Drupal::keyValue('migrate_interruption_result')->get($this->id(), static::RESULT_INCOMPLETE);

Can we inject the key value service as well.

+++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php
@@ -226,18 +226,9 @@ protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids)
+    return Migration::create(\Drupal::getContainer(), [], $id, $definition);

So much better! alexpott++

alexpott’s picture

Issue tags: -beta target
alexpott’s picture

@benjy the reason I didn't inject state yet was because the need to inject the factory not each service - inject factories feels wrong... I'd rather have a MigrationState service or something that offers methods to access all the different migration state collections.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

OK, that works for me.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Patch looks like a good step forward. I wanted to see if there were any other \Drupal:: calls to be removed, but couldn't find anything that should hold this going in.

Needs a re-roll after the change to Kernel tests - several hunks no longer apply.

alexpott’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new30.32 KB

Rerolled.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

  • catch committed 2c35bee on 8.2.x
    Issue #2666650 by alexpott, benjy: Inject migration and source plugin...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.