Browse Source

DDST-188 : Make module drush 12 compatible

pull/23/head
Prashant Kanse 7 months ago
parent
commit
92c4bf746d
  1. 12
      dgi_fixity.services.yml
  2. 53
      src/FixityCheckService.php

12
dgi_fixity.services.yml

@ -1,11 +1,9 @@
services:
logger.channel.dgi_fixity:
class: Drupal\Core\Logger\LoggerChannel
factory: logger.factory:get
arguments: ['dgi_fixity']
dgi_fixity.fixity_check:
class: Drupal\dgi_fixity\FixityCheckService
arguments: ['@string_translation', '@config.factory', '@entity_type.manager', '@datetime.time', '@plugin.manager.mail', '@logger.channel.dgi_fixity', '@filehash']
arguments: ['@string_translation', '@config.factory', '@entity_type.manager', '@datetime.time', '@filehash']
calls:
- [setLoggerFactory, ['@logger.factory']]
dgi_fixity.route_subscriber:
class: Drupal\dgi_fixity\Routing\FixityCheckRouteSubscriber
arguments: ['@entity_type.manager', '@dgi_fixity.fixity_check']
@ -16,3 +14,7 @@ services:
arguments: ['@entity_type.manager', '@entity.repository', '@dgi_fixity.fixity_check']
tags:
- { name: paramconverter }
logger.channel.dgi_fixity:
class: Drupal\Core\Logger\LoggerChannel
factory: logger.factory:get
arguments: ['dgi_fixity']

53
src/FixityCheckService.php

@ -7,7 +7,6 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Link;
use Drupal\Core\Mail\MailManagerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\dgi_fixity\Entity\FixityCheck;
@ -19,6 +18,7 @@ use Drupal\media\MediaInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
use Psr\Log\LoggerInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
/**
* Decorates the FileHash services adding additional functionality.
@ -48,13 +48,6 @@ class FixityCheckService implements FixityCheckServiceInterface {
*/
protected $time;
/**
* The mail manager service.
*
* @var \Drupal\Core\Mail\MailManagerInterface
*/
protected $mailManager;
/**
* The logger for this service.
*
@ -69,19 +62,53 @@ class FixityCheckService implements FixityCheckServiceInterface {
*/
protected $filehash;
/**
* The logger factory.
*
* @var \Drupal\Core\Logger\LoggerChannelFactoryInterface
*/
protected LoggerChannelFactoryInterface $loggerFactory;
/**
* Constructor.
*/
public function __construct(TranslationInterface $string_translation, ConfigFactoryInterface $config, EntityTypeManagerInterface $entity_type_manager, TimeInterface $time, MailManagerInterface $mail_manager, LoggerInterface $logger, FileHash $filehash) {
public function __construct(
TranslationInterface $string_translation,
ConfigFactoryInterface $config,
EntityTypeManagerInterface $entity_type_manager,
TimeInterface $time,
FileHash $filehash
) {
$this->stringTranslation = $string_translation;
$this->config = $config;
$this->entityTypeManager = $entity_type_manager;
$this->time = $time;
$this->mailManager = $mail_manager;
$this->logger = $logger;
$this->filehash = $filehash;
}
/**
* Sets the logger factory.
*
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory
* The logger factory.
*/
public function setLoggerFactory(LoggerChannelFactoryInterface $loggerFactory) {
$this->loggerFactory = $loggerFactory;
}
/**
* Gets the logger channel.
*
* @return \Psr\Log\LoggerInterface
* The logger channel.
*/
protected function getLogger() {
if (!isset($this->logger)) {
$this->logger = $this->loggerFactory->get('dgi_fixity');
}
return $this->logger;
}
/**
* {@inheritdoc}
*/
@ -272,10 +299,10 @@ class FixityCheckService implements FixityCheckServiceInterface {
)->toString(),
];
if ($check->passed()) {
$this->logger->info($message, $args);
$this->getLogger()->info($message, $args);
}
else {
$this->logger->error($message, $args);
$this->getLogger()->error($message, $args);
}
return $check;

Loading…
Cancel
Save