/** * Overrides Drupal\configuration\Config\PermissionConfiguration::alterDependencies(). */ public static function alterDependencies(Configuration $config) { parent::alterDependencies($config); $id = $config->getIdentifier(); // Rules components that involve permissions should have the permission // bundled along with it, but it's not necessary, so we add as optional. if ($config->getComponent() == 'rules_config') { $rule_name = $id; $rules_permissions = rules_permission(); $permission = "use Rules component {$rule_name}"; if (isset($rules_permissions[$permission])) { $identifier = str_replace(' ', '_', $permission); $perm = new YafflePermissionConfiguration($identifier); $perm->build(); // Add the Rules component as a dependency of the permission. // NOTE: This isn't working, so we're adding the dependency below. // $perm->addToDependencies($config); // Add the permission as a child configuration of the Rules component. $config->addToOptionalConfigurations($perm); } } // Permissions for Rules components require the component in place first // otherwise we will start seeing errors. if ($config->getComponent() == 'permission' && strpos($id, 'use_Rules_component') !== FALSE) { $rule_name = substr($id, 20); $rules_config = ConfigurationManagement::createConfigurationInstance('rules_config.' . $rule_name); $config->addToDependencies($rules_config); } }