You are here

public function PermissionConfigurationHandler::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/PermissionConfigurationHandler.php, line 95

Class

PermissionConfigurationHandler

Namespace

Configuration\Handlers

Code

public function writeToDatabase(Configuration $configuration) {
  $name = $this
    ->getInternalId($configuration
    ->getIdentifier());
  $event = $this
    ->triggerEvent('write_to_database', $configuration);
  $permission = $event->configuration
    ->getData();

  // Delete all the configured roles for this permission.
  $this->configuration_manager
    ->drupal()
    ->permission_deletePermission($permission['permission']);
  $this->configuration_manager
    ->drupal()
    ->permission_savePermission($permission);

  // Clear the user access cache.
  $this->configuration_manager
    ->drupal()
    ->drupal_static_reset('user_access');
  $this->configuration_manager
    ->drupal()
    ->drupal_static_reset('user_role_permissions');
}