You are here

DefaultValue.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php

File

core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php
View source
<?php

/**
 * @file
 * Contains \Drupal\migrate\Plugin\migrate\process\DefaultValue.
 */
namespace Drupal\migrate\Plugin\migrate\process;

use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;

/**
 * This plugin sets missing values on the destination.
 *
 * @MigrateProcessPlugin(
 *   id = "default_value"
 * )
 */
class DefaultValue extends ProcessPluginBase {

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

}

Classes

Namesort descending Description
DefaultValue This plugin sets missing values on the destination.