abstract class BynderException in Bynder 8.3
Same name and namespace in other branches
- 8 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 MessengerTrait, StringTranslationTrait
Expanded class hierarchy of BynderException
3 files declare their use of BynderException
- BynderUpload.php in src/
Plugin/ EntityBrowser/ Widget/ BynderUpload.php - UnableToAddUsageException.php in modules/
bynder_usage/ src/ Exception/ UnableToAddUsageException.php - UnableToDeleteUsageException.php in modules/
bynder_usage/ src/ Exception/ UnableToDeleteUsageException.php
File
- src/
Exception/ BynderException.php, line 11
Namespace
Drupal\bynder\ExceptionView source
abstract class BynderException extends \Exception {
use StringTranslationTrait;
use MessengerTrait;
/**
* Admin permission related to this exception.
*
* @var string
*/
protected $adminPermission = 'administer bynder configuration';
/**
* 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)) {
$this
->messenger()
->addError($this->adminMessage);
}
else {
$this
->messenger()
->addError($this
->getMessage());
}
}
/**
* 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:: |
public | function | Displays message to the user. | |
BynderException:: |
public | function | Logs exception into Drupal's log. | |
BynderException:: |
public | function | Constructs BundleNotExistException. | 9 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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. |