You are here

abstract class SalesforceExceptionEvent in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 src/Event/SalesforceExceptionEvent.php \Drupal\salesforce\Event\SalesforceExceptionEvent
  2. 5.0.x src/Event/SalesforceExceptionEvent.php \Drupal\salesforce\Event\SalesforceExceptionEvent

Base class for Salesforce Exception events, primarily for logging.

Hierarchy

Expanded class hierarchy of SalesforceExceptionEvent

File

src/Event/SalesforceExceptionEvent.php, line 8

Namespace

Drupal\salesforce\Event
View source
abstract class SalesforceExceptionEvent extends SalesforceBaseEvent implements SalesforceExceptionEventInterface {

  /**
   * Exception.
   *
   * @var \Exception|null
   */
  protected $exception;

  /**
   * Message for logging.
   *
   * @var string
   */
  protected $message;

  /**
   * Context, for t() translation.
   *
   * @var array
   */
  protected $context;

  /**
   * Event level: notice, warning, or error.
   *
   * @var string
   */
  protected $level;

  /**
   * SalesforceExceptionEvent constructor.
   *
   * @param string $level
   *   Values are RfcLogLevel::NOTICE, RfcLogLevel::WARNING, RfcLogLevel::ERROR.
   * @param \Exception|null $e
   *   A related Exception, if available.
   * @param string $message
   *   The translatable message string, suitable for t().
   * @param array $context
   *   Parameter array suitable for t(), to be translated for $message.
   */
  public function __construct($level, \Exception $e = NULL, $message = '', array $context = []) {
    $this->exception = $e;
    $this->level = $level;
    $this->message = $message;
    $this->context = $context;
  }

  /**
   * {@inheritdoc}
   */
  public function getException() {
    return $this->exception;
  }

  /**
   * {@inheritdoc}
   */
  public function getLevel() {
    return $this->level;
  }

  /**
   * {@inheritdoc}
   */
  public function getMessage() {
    if ($this->message) {
      return $this->message;
    }
    elseif ($this->exception && $this->exception
      ->getMessage()) {
      return $this->exception
        ->getMessage();
    }
    else {
      return 'Unknown Salesforce event.';
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return $this->context;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SalesforceExceptionEvent::$context protected property Context, for t() translation.
SalesforceExceptionEvent::$exception protected property Exception.
SalesforceExceptionEvent::$level protected property Event level: notice, warning, or error.
SalesforceExceptionEvent::$message protected property Message for logging.
SalesforceExceptionEvent::getContext public function Getter for message context. Overrides SalesforceExceptionEventInterface::getContext
SalesforceExceptionEvent::getException public function Getter for exception. Overrides SalesforceExceptionEventInterface::getException
SalesforceExceptionEvent::getLevel public function Getter for log level. Overrides SalesforceExceptionEventInterface::getLevel
SalesforceExceptionEvent::getMessage public function Getter for message string. Overrides SalesforceExceptionEventInterface::getMessage
SalesforceExceptionEvent::__construct public function SalesforceExceptionEvent constructor. 3