- last update
about 1 year ago 1 pass, 2 fail - last update
about 1 year ago 2 pass - Status changed to Needs work
3 months ago 1:53pm 14 February 2025 - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
Please put the patch into a issue fork and create a merge request.
A migrate process plugin to migrate an existing Tablefield data from D7 to D8 would be very helpful.
In the meatime, I created a following process plugin in my custom module that worked for me (replace my_module with name of your custom module you want to place process plugin into + read doc comments below to configure a migration of caption properly):
<?php
namespace Drupal\my_module\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
/**
* Migrates Tablefield content from D7 to D8.
*
* @MigrateProcessPlugin(
* id = "tablefield"
* )
*
* Optionally, "captionField" configuration can specify configuration target
* field where caption should be stored (in D7 TableField, this was part of the
* field data)
*
* Example usage:
* @code
* field_table/value:
* plugin: tablefield
* captionField: field_caption
* source: field_table/0/value
* @endcode
*/
class Tablefield extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$data = unserialize($value);
if (!$data) {
return NULL;
}
$targetData = [];
if (isset($this->configuration['captionField'])) {
$row->setDestinationProperty($this->configuration['captionField'], $data['caption']);
}
foreach ($data as $key => $val) {
if (strpos($key, 'cell_') === 0) {
$keyParts = explode('_', $key);
$x = $keyParts[1];
$y = $keyParts[2];
$targetData[$x][$y] = $val;
}
}
return $targetData;
}
}
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Please put the patch into a issue fork and create a merge request.