Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Nov 22, 2024
1 parent 738e3e9 commit e0455d9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/ContentMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,27 @@ protected function migrateGridRow($row, $fieldConfigs)
})->all();
}

protected function migrateLinkitField($handle, $value, $config)
{
if ($value['type'] === 'asset') {
// Use Statamic's migration logic which handles URLs, but they are
// returned without container id prefixes, and LinkIt expects them.
$asset = $this->migrateAssetsField(null, $value['asset'], ['container' => $value['container']]);
$value['asset'] = collect($asset)->map(fn ($a) => $value['container'].'::'.$a)->all();
}

if ($value['type'] === 'term') {
$value['term'] = collect($value['term'])->map(fn ($t) => str($t)->replace('/', '::')->toString())->all();
}

if ($value['type'] === 'page') {
$value['type'] = 'entry';
$value['entry'] = Arr::pull($value, 'page');
}

return $value;
}

/**
* Migrate fieldset to blueprint.
*
Expand Down
13 changes: 13 additions & 0 deletions src/FieldsetMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,19 @@ protected function migrateDateField($config, $handle)
return $config;
}

protected function migrateLinkitField($config, $handle)
{
// LinkIt in v2 always allowed pages without any extra config.
// In v3 it only deals with entries, so we'll add pages all the time.
if ($config->has('collections')) {
$config['collections'] = collect($config['collections'])->push('pages')->unique()->all();
} else {
$config['collections'] = ['pages'];
}

return $config;
}

/**
* Convert partial field to import.
*
Expand Down

0 comments on commit e0455d9

Please sign in to comment.