class ErrorLevelConfigOverride in Error Level Permission 8
Hierarchy
- class \Drupal\errorlevelpermission\ErrorLevelConfigOverride implements ConfigFactoryOverrideInterface
Expanded class hierarchy of ErrorLevelConfigOverride
1 string reference to 'ErrorLevelConfigOverride'
1 service uses ErrorLevelConfigOverride
File
- src/
ErrorLevelConfigOverride.php, line 9
Namespace
Drupal\errorlevelpermissionView source
class ErrorLevelConfigOverride implements ConfigFactoryOverrideInterface {
/**
* {@inheritdoc}
*/
public function loadOverrides($names) {
$overrides = [];
if (in_array('system.logging', $names)) {
$overrides['system.logging']['error_level'] = $this
->errorLevel();
}
return $overrides;
}
/**
* Get error level value depending on user permissions.
*
* @return string
* The error level.
*/
protected function errorLevel() {
$currentUser = \Drupal::currentUser();
if ($currentUser
->hasPermission('errorlevelpermission display verbose')) {
return ERROR_REPORTING_DISPLAY_VERBOSE;
}
elseif ($currentUser
->hasPermission('errorlevelpermission display all')) {
return ERROR_REPORTING_DISPLAY_ALL;
}
elseif ($currentUser
->hasPermission('errorlevelpermission display some')) {
return ERROR_REPORTING_DISPLAY_SOME;
}
else {
return ERROR_REPORTING_HIDE;
}
}
/**
* {@inheritdoc}
*/
public function getCacheSuffix() {
return 'errorlevelpermission';
}
/**
* {@inheritdoc}
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata($name) {
$cacheableMetadata = new CacheableMetadata();
$cacheableMetadata
->addCacheContexts([
'user.permissions',
]);
return $cacheableMetadata;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ErrorLevelConfigOverride:: |
public | function |
Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface:: |
|
ErrorLevelConfigOverride:: |
protected | function | Get error level value depending on user permissions. | |
ErrorLevelConfigOverride:: |
public | function |
Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface:: |
|
ErrorLevelConfigOverride:: |
public | function |
The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface:: |
|
ErrorLevelConfigOverride:: |
public | function |
Returns config overrides. Overrides ConfigFactoryOverrideInterface:: |