/**
  * 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);
     }
 }
Ejemplo n.º 2
0
 /**
  * Overrides Drupal\configuration\Config\Configuration::alterDependencies().
  */
 public static function alterDependencies(Configuration $config)
 {
     if ($config->getComponent() == 'content_type') {
         $permissions = node_list_permissions($config->getIdentifier());
         foreach (array_keys($permissions) as $permission) {
             $identifier = str_replace(' ', '_', $permission);
             $perm = new PermissionConfiguration($identifier);
             $perm->build();
             // Add the content type as a dependency of the permission.
             $perm->addToDependencies($config);
             // Add the permission as a child configuration of the content type
             // The permission is not required to load the content type but is
             // a nice to have.
             $config->addToOptionalConfigurations($perm);
         }
     } elseif ($config->getComponent() == 'text_format') {
         $format = $config->getData();
         $permission = filter_permission_name($format);
         if (!empty($permission)) {
             $identifier = str_replace(' ', '_', $permission);
             $perm = new PermissionConfiguration($identifier);
             $perm->build();
             // Add the text format as a dependency of the permission.
             $perm->addToDependencies($config);
             // Add the permission as a child configuration of the filter
             // The permission is not required to load the filter format but is
             // a nice to have.
             $config->addToOptionalConfigurations($perm);
         }
     }
 }