Skip to content

Commit e0455d9

Browse files
committed
wip
1 parent 738e3e9 commit e0455d9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/ContentMigrator.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,27 @@ protected function migrateGridRow($row, $fieldConfigs)
387387
})->all();
388388
}
389389

390+
protected function migrateLinkitField($handle, $value, $config)
391+
{
392+
if ($value['type'] === 'asset') {
393+
// Use Statamic's migration logic which handles URLs, but they are
394+
// returned without container id prefixes, and LinkIt expects them.
395+
$asset = $this->migrateAssetsField(null, $value['asset'], ['container' => $value['container']]);
396+
$value['asset'] = collect($asset)->map(fn ($a) => $value['container'].'::'.$a)->all();
397+
}
398+
399+
if ($value['type'] === 'term') {
400+
$value['term'] = collect($value['term'])->map(fn ($t) => str($t)->replace('/', '::')->toString())->all();
401+
}
402+
403+
if ($value['type'] === 'page') {
404+
$value['type'] = 'entry';
405+
$value['entry'] = Arr::pull($value, 'page');
406+
}
407+
408+
return $value;
409+
}
410+
390411
/**
391412
* Migrate fieldset to blueprint.
392413
*

src/FieldsetMigrator.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,19 @@ protected function migrateDateField($config, $handle)
524524
return $config;
525525
}
526526

527+
protected function migrateLinkitField($config, $handle)
528+
{
529+
// LinkIt in v2 always allowed pages without any extra config.
530+
// In v3 it only deals with entries, so we'll add pages all the time.
531+
if ($config->has('collections')) {
532+
$config['collections'] = collect($config['collections'])->push('pages')->unique()->all();
533+
} else {
534+
$config['collections'] = ['pages'];
535+
}
536+
537+
return $config;
538+
}
539+
527540
/**
528541
* Convert partial field to import.
529542
*

0 commit comments

Comments
 (0)