Commit 52195a8a authored by Randal V's avatar Randal V Committed by Sven Decabooter
Browse files

Issue #3264438 by RandalV: addLogWithSeverity method isn't compatible with the interface

parent 82658f16
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ class EntityLogEntry extends ContentEntityBase implements EntityLogEntryInterfac

    // Add the owner field.
    $fields += static::ownerBaseFieldDefinitions($entity_type);
    $fields['user_id']
    $fields['uid']
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);

+13 −12
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Drupal\entity_logger;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Logger\RfcLogLevel;
use Drupal\entity_logger\Entity\EntityLogEntryInterface;

/**
 * Defines an instance class, to log against a specified entity and log channel.
@@ -60,46 +61,46 @@ class EntityLoggerInstance implements EntityLoggerInstanceInterface {
  /**
   * {@inheritdoc}
   */
  public function addLogWithSeverity(string $message, array $context = [], int $severity = RfcLogLevel::INFO) {
  public function addLogWithSeverity(string $message, array $context = [], int $severity = RfcLogLevel::INFO): ?EntityLogEntryInterface {
    if (!$this->entity) {
      return NULL;
    }
    $this->entityLogger->log($this->entity, $message, $context, $severity, $this->channel);
    return $this->entityLogger->log($this->entity, $message, $context, $severity, $this->channel);
  }

  /**
   * {@inheritdoc}
   */
  public function addLog(string $message, array $context = []) {
    $this->addLogWithSeverity($message, $context);
  public function addLog(string $message, array $context = []): ?EntityLogEntryInterface {
    return $this->addLogWithSeverity($message, $context);
  }

  /**
   * {@inheritdoc}
   */
  public function addInfoLog(string $message, array $context = []) {
    $this->addLogWithSeverity($message, $context);
  public function addInfoLog(string $message, array $context = []): ?EntityLogEntryInterface {
    return $this->addLogWithSeverity($message, $context);
  }

  /**
   * {@inheritdoc}
   */
  public function addNoticeLog(string $message, array $context = []) {
    $this->addLogWithSeverity($message, $context, RfcLogLevel::NOTICE);
  public function addNoticeLog(string $message, array $context = []): ?EntityLogEntryInterface {
    return $this->addLogWithSeverity($message, $context, RfcLogLevel::NOTICE);
  }

  /**
   * {@inheritdoc}
   */
  public function addWarningLog(string $message, array $context = []) {
    $this->addLogWithSeverity($message, $context, RfcLogLevel::WARNING);
  public function addWarningLog(string $message, array $context = []): ?EntityLogEntryInterface {
    return $this->addLogWithSeverity($message, $context, RfcLogLevel::WARNING);
  }

  /**
   * {@inheritdoc}
   */
  public function addErrorLog(string $message, array $context = []) {
    $this->addLogWithSeverity($message, $context, RfcLogLevel::ERROR);
  public function addErrorLog(string $message, array $context = []): ?EntityLogEntryInterface {
    return $this->addLogWithSeverity($message, $context, RfcLogLevel::ERROR);
  }

}