class Drupal8Config in Rocket.Chat 8
Same name and namespace in other branches
- 8.2 modules/rocket_chat_api/src/RocketChat/Drupal8Config.php \Drupal\rocket_chat_api\RocketChat\Drupal8Config
Class Drupal8Config connects the API with the drupal system.
@package RocketChat
Hierarchy
- class \Drupal\rocket_chat_api\RocketChat\Drupal8Config implements ContainerInjectionInterface, RocketChatConfigInterface
Expanded class hierarchy of Drupal8Config
2 files declare their use of Drupal8Config
- ApiTestForm.php in modules/
rocket_chat_api_test/ src/ Form/ ApiTestForm.php - Contains \Drupal\rocket_chat_api_test\Form\ApiTestForm.
- RocketChatSettingsForm.php in src/
Form/ RocketChatSettingsForm.php - Contains \Drupal\rocket_chat\Form\RocketChatSettingsForm.
File
- modules/
rocket_chat_api/ src/ RocketChat/ Drupal8Config.php, line 23
Namespace
Drupal\rocket_chat_api\RocketChatView source
class Drupal8Config implements RocketChatConfigInterface, ContainerInjectionInterface {
/**
* The config factory.
*
* Subclasses should use the self::config() method, which may be overridden
* to address specific needs when loading config, rather than this property
* directly.
* See \Drupal\Core\Form\ConfigFormBase::config() for an example of this.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $config;
protected $moduleHandler;
protected $state;
/**
* Constructs a \Drupal\system\ConfigFormBase object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The ModuleHandler to interact with loaded modules.
* @param \Drupal\Core\State\StateInterface $state
* The state interface to manipulate the States.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $moduleHandler, StateInterface $state) {
$this->config = $config_factory
->get('rocket_chat.settings');
$this->moduleHandler = $moduleHandler;
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('module_handler'), $container
->get('state'));
}
/**
* {@inheritdoc}
*/
public function getElement($elementName, $default = NULL) {
switch ($elementName) {
case 'rocket_chat_url':
// Fallthrough and modify.
$elementName = "server";
default:
$value = $this->config
->get($elementName);
if (empty($value)) {
$value = $default;
}
return $value;
case 'rocket_chat_uid':
// Fallthrough.
case 'rocket_chat_uit':
// Fallthrough.
return $this->state
->get($elementName, $default);
}
}
/**
* {@inheritdoc}
*/
public function setElement($elementName, $newValue) {
$config = $this->config;
switch ($elementName) {
case 'rocket_chat_url':
// Fallthrough and modify.
$elementName = "url";
default:
$config
->clear($elementName)
->set($elementName, $newValue)
->save();
break;
case 'rocket_chat_uid':
// Fallthrough.
case 'rocket_chat_uit':
// Fallthrough.
$this->state
->delete($elementName);
if (!empty($newValue)) {
$this->state
->set($elementName, $newValue);
}
break;
}
}
/**
* {@inheritdoc}
*/
public function isDebug() {
return $this->moduleHandler
->moduleExists('devel');
}
/**
* {@inheritdoc}
*/
public function getJsonDecoder() {
return '\\Drupal\\Component\\Serialization\\Json::decode';
}
/**
* {@inheritdoc}
*/
public function notify($message, $type) {
return drupal_set_message($message, $type);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Drupal8Config:: |
protected | property | The config factory. | |
Drupal8Config:: |
protected | property | ||
Drupal8Config:: |
protected | property | ||
Drupal8Config:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Drupal8Config:: |
public | function |
Get a RocketChatConfigInterface Element. Overrides RocketChatConfigInterface:: |
1 |
Drupal8Config:: |
public | function |
Get a function pointer to the function to use for JsonDecodeing. Overrides RocketChatConfigInterface:: |
|
Drupal8Config:: |
public | function |
Is this a Debug / verbose Run. Overrides RocketChatConfigInterface:: |
1 |
Drupal8Config:: |
public | function |
Notify the backend. Overrides RocketChatConfigInterface:: |
1 |
Drupal8Config:: |
public | function |
Set an Element in the RocketChatConfigInterface. Overrides RocketChatConfigInterface:: |
1 |
Drupal8Config:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. |