function DefaultValue::transform

Same name in other branches
  1. 8.9.x core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php \Drupal\migrate\Plugin\migrate\process\DefaultValue::transform()
  2. 10 core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php \Drupal\migrate\Plugin\migrate\process\DefaultValue::transform()
  3. 11.x core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php \Drupal\migrate\Plugin\migrate\process\DefaultValue::transform()

Overrides ProcessPluginBase::transform

File

core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php, line 54

Class

DefaultValue
Returns a given default value if the input is empty.

Namespace

Drupal\migrate\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    if (!empty($this->configuration['strict'])) {
        return $value ?? $this->configuration['default_value'];
    }
    return $value ?: $this->configuration['default_value'];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.