Migration.php in Migrate Plus 8.2
File
src/Entity/Migration.php
View source
<?php
namespace Drupal\migrate_plus\Entity;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
class Migration extends ConfigEntityBase implements MigrationInterface {
protected $id;
protected $label;
protected function invalidateTagsOnSave($update) {
parent::invalidateTagsOnSave($update);
Cache::invalidateTags([
'migration_plugins',
]);
}
protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities) {
parent::invalidateTagsOnDelete($entity_type, $entities);
Cache::invalidateTags([
'migration_plugins',
]);
}
public static function createEntityFromPlugin($plugin_id, $new_plugin_id) {
$plugin_manager = \Drupal::service('plugin.manager.migration');
$migration_plugin = $plugin_manager
->createInstance($plugin_id);
$entity_array['id'] = $new_plugin_id;
$entity_array['migration_tags'] = $migration_plugin
->get('migration_tags');
$entity_array['label'] = $migration_plugin
->label();
$entity_array['source'] = $migration_plugin
->getSourceConfiguration();
$entity_array['destination'] = $migration_plugin
->getDestinationConfiguration();
$entity_array['process'] = $migration_plugin
->getProcess();
$entity_array['migration_dependencies'] = $migration_plugin
->getMigrationDependencies();
$migration_entity = static::create($entity_array);
return $migration_entity;
}
}