abstract class BynderException in Bynder 8
Same name and namespace in other branches
- 8.3 src/Exception/BynderException.php \Drupal\bynder\Exception\BynderException
- 8.2 src/Exception/BynderException.php \Drupal\bynder\Exception\BynderException
- 4.0.x src/Exception/BynderException.php \Drupal\bynder\Exception\BynderException
Base exception class for Bynder.
Hierarchy
- class \Drupal\bynder\Exception\BynderException extends \Drupal\bynder\Exception\Exception uses StringTranslationTrait
Expanded class hierarchy of BynderException
1 file declares its use of BynderException
- BynderUpload.php in src/
Plugin/ EntityBrowser/ Widget/ BynderUpload.php
File
- src/
Exception/ BynderException.php, line 10
Namespace
Drupal\bynder\ExceptionView source
abstract class BynderException extends \Exception {
use StringTranslationTrait;
/**
* Admin permission related to this exception.
*
* @var string
*/
protected $adminPermission = 'administer bynder configuration';
/**
* Message level to be used when displaying the message to the user.
*
* @var string
*/
protected $messageLevel = 'error';
/**
* User-facing for admin users.
*
* @var string
*/
protected $adminMessage;
/**
* Message to be logged in the Drupal's log.
*
* @var string
*/
protected $logMessage;
/**
* Arguments for the log message.
*
* @var array
*/
protected $logMessageArgs;
/**
* Constructs BundleNotExistException.
*/
public function __construct($message, $admin_message = NULL, $log_message = NULL, $log_message_args = []) {
$this->adminMessage = $admin_message ?: $message;
$this->logMessage = $log_message ?: $this->adminMessage;
$this->logMessageArgs = $log_message_args;
parent::__construct($message);
}
/**
* Displays message to the user.
*/
public function displayMessage() {
if (\Drupal::currentUser()
->hasPermission($this->adminPermission)) {
drupal_set_message($this->adminMessage, $this->messageLevel);
}
else {
drupal_set_message($this
->getMessage(), $this->messageLevel);
}
}
/**
* Logs exception into Drupal's log.
*
* @return \Drupal\bynder\Exception\BynderException
* This exception.
*/
public function logException() {
\Drupal::logger('bynder')
->error($this->logMessage, $this->logMessageArgs);
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BynderException:: |
protected | property | User-facing for admin users. | |
BynderException:: |
protected | property | Admin permission related to this exception. | 2 |
BynderException:: |
protected | property | Message to be logged in the Drupal's log. | |
BynderException:: |
protected | property | Arguments for the log message. | |
BynderException:: |
protected | property | Message level to be used when displaying the message to the user. | |
BynderException:: |
public | function | Displays message to the user. | |
BynderException:: |
public | function | Logs exception into Drupal's log. | |
BynderException:: |
public | function | Constructs BundleNotExistException. | 9 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |