You are here

class DrushLogMigrateMessage in Migrate Manifest 8

Same name and namespace in other branches
  1. 8.2 src/DrushLogMigrateMessage.php \Drupal\migrate_manifest\DrushLogMigrateMessage
  2. 3.x src/DrushLogMigrateMessage.php \Drupal\migrate_manifest\DrushLogMigrateMessage

Simple Migrate Message implementation that uses drush to output.

@package Drupal\migrate_manifest

Hierarchy

Expanded class hierarchy of DrushLogMigrateMessage

1 file declares its use of DrushLogMigrateMessage
DrushLogMigrateMessageTest.php in tests/src/Unit/DrushLogMigrateMessageTest.php

File

src/DrushLogMigrateMessage.php, line 14

Namespace

Drupal\migrate_manifest
View source
class DrushLogMigrateMessage implements MigrateMessageInterface {

  /**
   * @var \Psr\Log\LoggerInterface
   */
  protected $logger;
  public function __construct(LoggerInterface $logger = NULL) {
    if (!isset($logger)) {
      $logger = Drush::logger();
    }
    $this->logger = $logger;
  }

  /**
   * @inheritdoc
   */
  public function display($message, $type = 'status') {
    if (method_exists($this->logger, $type)) {
      $this->logger
        ->{$type}($message);
    }
    elseif ($type == 'status') {
      $this->logger
        ->info($message);
    }
    else {
      $this->logger
        ->warning('Logger called with unknown type: @type', [
        '@type' => $type,
      ]);
      $this->logger
        ->info($message);
    }
  }

}

Members