You are here

public function Drupal8Config::setElement in Rocket.Chat 8

Same name and namespace in other branches
  1. 8.2 modules/rocket_chat_api/src/RocketChat/Drupal8Config.php \Drupal\rocket_chat_api\RocketChat\Drupal8Config::setElement()

Set an Element in the RocketChatConfigInterface.

Parameters

string $elementName: Key value to set in the RocketChatConfigInterface Backend.

string $newValue: the new Value to store.

Overrides RocketChatConfigInterface::setElement

1 method overrides Drupal8Config::setElement()
Test7Config::setElement in modules/rocket_chat_api/src/RocketChat/TestConfig.class.inc
Set an Element in the RocketChatConfigInterface.

File

modules/rocket_chat_api/src/RocketChat/Drupal8Config.php, line 95

Class

Drupal8Config
Class Drupal8Config connects the API with the drupal system.

Namespace

Drupal\rocket_chat_api\RocketChat

Code

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;
  }
}