class ConnectorException in Acquia Connector 8
Same name and namespace in other branches
- 8.2 src/ConnectorException.php \Drupal\acquia_connector\ConnectorException
- 3.x src/ConnectorException.php \Drupal\acquia_connector\ConnectorException
Produce an exception for certain cases in the connector.
@package Drupal\acquia_connector
Hierarchy
- class \Drupal\acquia_connector\ConnectorException extends \Drupal\acquia_connector\Exception
Expanded class hierarchy of ConnectorException
3 files declare their use of ConnectorException
- CredentialForm.php in src/
Form/ CredentialForm.php - SettingsForm.php in src/
Form/ SettingsForm.php - SetupForm.php in src/
Form/ SetupForm.php
File
- src/
ConnectorException.php, line 10
Namespace
Drupal\acquia_connectorView source
class ConnectorException extends \Exception {
/**
* Custom exception messages.
*
* @var string[]
* Exception messages as key => value.
*/
private $custom = [];
/**
* ConnectorException constructor.
*
* @param string $message
* Exception message.
* @param int $code
* Exception code.
* @param array $custom
* Exception messages as key => value.
* @param \Exception|null $previous
* The previous exception used for the exception chaining. Since 5.3.0.
*/
public function __construct($message, $code = 0, array $custom = [], \Exception $previous = NULL) {
parent::__construct($message, $code, $previous);
$this->custom = $custom;
}
/**
* Check is customized.
*
* @return bool
* TRUE if not custom message is not empty, FALSE otherwise.
*/
public function isCustomized() {
return !empty($this->custom);
}
/**
* Set custom message.
*
* @param mixed $value
* Custom message value.
* @param string $key
* Custom message key.
*/
public function setCustomMessage($value, $key = 'message') {
$this->custom[$key] = $value;
}
/**
* Get custom message.
*
* @param string $key
* Custom message key.
* @param bool $fallback
* Default is TRUE. Return standard code or message.
*
* @return mixed
* Custom message of FALSE.
*/
public function getCustomMessage($key = 'message', $fallback = TRUE) {
if (isset($this->custom[$key])) {
return $this->custom[$key];
}
if (!$fallback) {
return FALSE;
}
switch ($key) {
case 'code':
return $this
->getCode();
case 'message':
return $this
->getMessage();
}
return FALSE;
}
/**
* Get all custom messages.
*
* @return array
* Array of custom messages.
*/
public function getAllCustomMessages() {
return $this->custom;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConnectorException:: |
private | property | Custom exception messages. | |
ConnectorException:: |
public | function | Get all custom messages. | |
ConnectorException:: |
public | function | Get custom message. | |
ConnectorException:: |
public | function | Check is customized. | |
ConnectorException:: |
public | function | Set custom message. | |
ConnectorException:: |
public | function | ConnectorException constructor. |