You are here

HookWatchdog.php in Drupal 7 to 8/9 Module Upgrader 8

File

src/Plugin/DMU/Converter/HookWatchdog.php
View source
<?php

namespace Drupal\drupalmoduleupgrader\Plugin\DMU\Converter;

use Drupal\drupalmoduleupgrader\ConverterBase;
use Drupal\drupalmoduleupgrader\TargetInterface;

/**
 * @Converter(
 *  id = "hook_watchdog",
 *  description = @Translation("Converts hook_watchdog() to an implementation of \\Psr\\Log\\LoggerInterface."),
 *  hook = "hook_watchdog"
 * )
 */
class HookWatchdog extends ConverterBase {

  /**
   * {@inheritdoc}
   */
  public function convert(TargetInterface $target) {
    $this
      ->writeService($target, 'default_logger', [
      'class' => 'Drupal\\' . $target
        ->id() . '\\Logger\\DefaultLogger',
      'tags' => [
        [
          'name' => 'logger',
        ],
      ],
    ]);
    $render = [
      '#theme' => 'dmu_logger',
      '#module' => $target
        ->id(),
    ];
    $this
      ->writeClass($target, $this
      ->parse($render));
  }

}

Classes

Namesort descending Description
HookWatchdog Plugin annotation @Converter( id = "hook_watchdog", description = @Translation("Converts hook_watchdog() to an implementation of \\Psr\\Log\\LoggerInterface."), hook = "hook_watchdog" )