You are here

public function RoleConfigurationHandler::writeToDatabase in Configuration Management 7.3

Saves the given configuration into the database.

Parameters

\Configuration\Configuration $configuration: The configuration to be saved.

Overrides ConfigurationHandler::writeToDatabase

File

src/Handlers/RoleConfigurationHandler.php, line 55

Class

RoleConfigurationHandler

Namespace

Configuration\Handlers

Code

public function writeToDatabase(Configuration $configuration) {
  $name = $this
    ->getInternalId($configuration
    ->getIdentifier());
  if ($name == 'anonymous_user' || $name == 'authenticated_user') {
    return;
  }
  $event = $this
    ->triggerEvent('write_to_database', $configuration);
  $role = $event->configuration
    ->getData();
  $existent_role = $this->configuration_manager
    ->drupal()
    ->role_roleExists($name);
  if ($existent_role) {

    // Updating an existent role.
    $role->rid = $existent_role;
  }
  $this->configuration_manager
    ->drupal()
    ->user_role_save($role);
}