You are here

public static function RoleConfiguration::alterDependencies in Configuration Management 7.2

Overrides Drupal\configuration\Config\Configuration::saveToActiveStore().

Overrides Configuration::alterDependencies

File

lib/Drupal/configuration/Config/RoleConfiguration.php, line 66
Definition of Drupal\configuration\Config\RoleConfiguration.

Class

RoleConfiguration

Namespace

Drupal\configuration\Config

Code

public static function alterDependencies(Configuration $config) {
  if ($config
    ->getComponent() == 'permission') {
    $data = $config
      ->getData();
    if (!empty($data['roles'])) {
      $role_objects = db_select('role', 'r')
        ->fields('r', array(
        'machine_name',
        'rid',
      ))
        ->condition('name', $data['roles'], 'IN')
        ->execute();
      foreach ($role_objects as $role_object) {
        if ($role_object->rid > 2 && !empty($role_object->machine_name)) {
          $role_config = ConfigurationManagement::createConfigurationInstance('role.' . $role_object->machine_name);
          $config
            ->addToDependencies($role_config);
        }
      }
    }
  }
}