Same name in this branch
  1. 10 core/lib/Drupal/Core/Database/Log.php \Drupal\Core\Database\Log
  2. 10 core/modules/migrate/src/Plugin/migrate/process/Log.php \Drupal\migrate\Plugin\migrate\process\Log
Same name and namespace in other branches
  1. 8.9.x core/modules/migrate/src/Plugin/migrate/process/Log.php \Drupal\migrate\Plugin\migrate\process\Log
  2. 9 core/modules/migrate/src/Plugin/migrate/process/Log.php \Drupal\migrate\Plugin\migrate\process\Log

Hierarchy

  • class \Drupal\migrate\Plugin\migrate\process\Log extends \Drupal\migrate\ProcessPluginBase

Expanded class hierarchy of Log

1 file declares its use of Log
LogTest.php in core/modules/migrate/tests/src/Unit/process/LogTest.php

File

core/modules/migrate/src/Plugin/migrate/process/Log.php, line 26

Namespace

Drupal\migrate\Plugin\migrate\process
View source
class Log extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $is_object = is_object($value);
    if (is_null($value) || is_bool($value)) {
      $export = var_export($value, TRUE);
    }
    elseif (is_float($value)) {
      $export = sprintf('%f', $value);
    }
    elseif ($is_object && method_exists($value, 'toString')) {
      $export = print_r($value
        ->toString(), TRUE);
    }
    elseif ($is_object && method_exists($value, 'toArray')) {
      $export = print_r($value
        ->toArray(), TRUE);
    }
    elseif (is_string($value) || is_numeric($value) || is_array($value)) {
      $export = print_r($value, TRUE);
    }
    elseif ($is_object && method_exists($value, '__toString')) {
      $export = print_r((string) $value, TRUE);
    }
    else {
      $export = NULL;
    }
    $class_name = $export !== NULL && $is_object ? $class_name = get_class($value) . ":\n" : '';
    $message = $export === NULL ? "Unable to log the value for '{$destination_property}'" : "'{$destination_property}' value is {$class_name}'{$export}'";

    // Log the value.
    $migrate_executable
      ->saveMessage($message);

    // Pass through the same value we received.
    return $value;
  }

}

Members