Commit 2c580e61 authored by Rico Van de Vin's avatar Rico Van de Vin Committed by Rick Hawkins
Browse files

Issue #3278542 by ricovandevin, rlhawk, nkoporec: Update $logger definition to...

Issue #3278542 by ricovandevin, rlhawk, nkoporec: Update $logger definition to be compatible with Drupal 10
parent fda1d3a4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
services:
  key.commands:
    class: Drupal\key\Commands\KeyCommands
    arguments: ['@key.repository', '@logger.factory', '@plugin.manager.key.key_type', '@entity_type.manager', '@plugin.manager.key.key_provider']
    arguments: ['@key.repository', '@plugin.manager.key.key_type', '@entity_type.manager', '@plugin.manager.key.key_provider']
    tags:
      - { name: drush.command }
+4 −14
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace Drupal\key\Commands;
use Consolidation\OutputFormatters\StructuredData\RowsOfFields;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\key\KeyRepositoryInterface;
use Drupal\key\Plugin\KeyPluginManager;
use Drush\Commands\DrushCommands;
@@ -39,13 +38,6 @@ class KeyCommands extends DrushCommands {
   */
  protected $entityTypeManager;

  /**
   * Logger object.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  /**
   * Key provider manager object.
   *
@@ -58,13 +50,11 @@ class KeyCommands extends DrushCommands {
   */
  public function __construct(
    KeyRepositoryInterface $repository,
    LoggerChannelFactoryInterface $logger,
    KeyPluginManager $key_plugin_manager,
    EntityTypeManagerInterface $entity_type_manager,
    KeyPluginManager $provider_manager
  ) {
    $this->repository = $repository;
    $this->logger = $logger->get('key');
    $this->keyTypePluginManager = $key_plugin_manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->keyProviderPluginManager = $provider_manager;
@@ -120,7 +110,7 @@ class KeyCommands extends DrushCommands {

    if ($existing_key) {
      // Add a warning about overwriting a key.
      $this->logger->warning('Be extremely careful when overwriting a key! It may result in losing access to a service or making encrypted data unreadable.');
      $this->logger()->warning('Be extremely careful when overwriting a key! It may result in losing access to a service or making encrypted data unreadable.');

      // Confirm that the key should be saved.
      $this->output->writeln(dt('The following key will be overwritten: !id', ['!id' => $values['id']]));
@@ -182,7 +172,7 @@ class KeyCommands extends DrushCommands {
      throw new \Exception(dt('Key !id was not saved.', ['!id' => $values['id']]));
    }

    $this->logger->info('Key !id was saved successfully.', ['!id' => $values['id']]);
    $this->logger()->info('Key !id was saved successfully.', ['!id' => $values['id']]);
  }

  /**
@@ -208,7 +198,7 @@ class KeyCommands extends DrushCommands {
    }

    // Confirm that the key should be deleted.
    $this->logger->warning('Be extremely careful when deleting a key! It may result in losing access to a service or making encrypted data unreadable.');
    $this->logger()->warning('Be extremely careful when deleting a key! It may result in losing access to a service or making encrypted data unreadable.');
    $this->output->writeln(dt('The following key will be deleted: !id', ['!id' => $id]));
    if (!$this->io()->confirm(dt('Do you want to continue?'))) {
      // Removing drush_user_abort(), no current implementation of that.
@@ -226,7 +216,7 @@ class KeyCommands extends DrushCommands {
      throw new \Exception(dt('Key !id was not deleted.', ['!id' => $id]));
    }

    $this->logger->info('Key !id was deleted successfully.', ['!id' => $id]);
    $this->logger()->info('Key !id was deleted successfully.', ['!id' => $id]);
  }

  /**