Skip to content
Snippets Groups Projects
Commit a763dde5 authored by Owen Bush's avatar Owen Bush
Browse files

Added fallback field inheritance

parent 08207dd2
No related branches found
No related tags found
No related merge requests found
......@@ -110,7 +110,7 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
switch ($method) {
case 'inherit':
$text = $series->{$field}->value ?? '';
$value = $series->{$field}->value ?? '';
break;
case 'prepend':
......@@ -126,7 +126,7 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
if (!empty($series->{$field}->value)) {
$fields[] = $series->{$field}->value;
}
$text = implode($this::SEPARATOR, $fields);
$value = implode($this::SEPARATOR, $fields);
break;
case 'append':
......@@ -142,7 +142,24 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
if (!empty($instance->{$entity_field}->value)) {
$fields[] = $instance->{$entity_field}->value;
}
$text = implode($this::SEPARATOR, $fields);
$value = implode($this::SEPARATOR, $fields);
break;
case 'fallback':
if (empty($this->getEntityField())) {
throw new \InvalidArgumentException("The definition's 'entity field' key must be set to fallback to series data.");
}
$entity_field = $this->getEntityField();
$value = '';
if (!empty($instance->{$entity_field}->value)) {
$value = $instance->{$entity_field}->value;
}
elseif (!empty($series->{$field}->value)) {
$value = $series->{$field}->value;
}
break;
default:
......@@ -150,7 +167,7 @@ abstract class FieldInheritancePluginBase extends PluginBase implements FieldInh
}
return $text;
return $value;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment