Commit 1c815988 authored by osopolar's avatar osopolar Committed by Damien McKenna
Browse files

Issue #2537248 by osopolar, Ronino, DamienMcKenna: Allow title without url on migration.

parent 7f65b557
Link 7.x-1.x-dev, xxxx-xx-xx
----------------------------
#2537248 by osopolar, Ronino, DamienMcKenna: Allow title without url on
migration.
Link 7.x-1.7, 2019-11-14
......
......@@ -102,7 +102,28 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
}
$language = $this->getFieldLanguage($entity, $field_info, $arguments);
$values = array_filter($values);
// URLs are numeric array elements, keyed by delta. As those elements don't
// exist for empty URLs they are allowed and it's up to the developer what
// data to migrate, add elements for those URLs up to the maximum delta
// found.
//
// First of all, determine the maximum delta from non-empty URLs.
$max_delta = max(array_merge(array(0), array_keys($values)));
// Next, determine the max delta from arguments.
foreach ($arguments as $key => $value) {
if (is_array($value)) {
$max_delta = max($max_delta, max(array_keys($value)));
}
}
// Finally, add missing elements for empty URLs.
for ($delta = 0; $delta <= $max_delta; $delta++) {
if (!isset($values[$delta])) {
$values[$delta] = '';
}
}
foreach ($values as $delta => $value) {
$item = array();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment