X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fblock%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FBlockPluginId.php;fp=web%2Fcore%2Fmodules%2Fblock%2Fsrc%2FPlugin%2Fmigrate%2Fprocess%2FBlockPluginId.php;h=08525674e3414531d0451242177a0cb0fe3f5715;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php b/web/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php new file mode 100644 index 000000000..08525674e --- /dev/null +++ b/web/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php @@ -0,0 +1,100 @@ +blockContentStorage = $storage; + $this->migrationPlugin = $migration_plugin; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + $entity_manager = $container->get('entity.manager'); + $migration_configuration = [ + 'migration' => [ + 'd6_custom_block', + 'd7_custom_block', + ], + ]; + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $entity_manager->getDefinition('block_content') ? $entity_manager->getStorage('block_content') : NULL, + $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration) + ); + } + + /** + * {@inheritdoc} + * + * Set the block plugin id. + */ + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { + if (is_array($value)) { + list($module, $delta) = $value; + switch ($module) { + case 'aggregator': + list($type, $id) = explode('-', $delta); + if ($type == 'feed') { + return 'aggregator_feed_block'; + } + break; + case 'menu': + return "system_menu_block:$delta"; + case 'block': + if ($this->blockContentStorage) { + $block_id = $this->migrationPlugin + ->transform($delta, $migrate_executable, $row, $destination_property); + if ($block_id) { + return 'block_content:' . $this->blockContentStorage->load($block_id)->uuid(); + } + } + break; + default: + break; + } + } + else { + return $value; + } + } + +}