og-8.x-1.x-dev/src/OgRoleManagerInterface.php
src/OgRoleManagerInterface.php
<?php
declare(strict_types=1);
namespace Drupal\og;
/**
* Defines an interface for OG role manager.
*/
interface OgRoleManagerInterface {
/**
* Creates the roles for the given group type, based on the default roles.
*
* This is intended to be called after a new group type has been created.
*/
public function createPerBundleRoles(string $entity_type_id, string $bundle_id): array;
/**
* Returns the default roles.
*
* @return \Drupal\og\Entity\OgRole[]
* An associative array of (unsaved) OgRole entities, keyed by role name.
* These are populated with the basic properties: name, label, role_type and
* is_admin.
*/
public function getDefaultRoles(): array;
/**
* Returns the roles which every group type requires.
*
* This provides the 'member' and 'non-member' roles. These are hard coded
* because they are strictly required and should not be altered.
*
* @return \Drupal\og\Entity\OgRole[]
* An associative array of (unsaved) required OgRole entities, keyed by role
* name. These are populated with the basic properties: name, label and
* role_type.
*/
public function getRequiredDefaultRoles(): array;
/**
* Returns all the roles of a provided group.
*/
public function getRolesByBundle(string $entity_type_id, string $bundle): array;
/**
* Returns all the roles that have a specific permission.
*
* Optionally filter the roles by entity type ID and bundle.
*
* @param array $permissions
* An array of permissions that the roles must have.
* @param string|null $entity_type_id
* (optional) The entity type ID of the group.
* @param string|null $bundle
* (optional) The bundle of the group.
* @param bool $require_all
* (optional) Whether all given permissions are required. When set to FALSE
* all roles that include one or more of the given permissions will be
* returned. Defaults to TRUE.
*
* @return \Drupal\og\OgRoleInterface[]
* An array of roles indexed by their IDs.
*/
public function getRolesByPermissions(array $permissions, ?string $entity_type_id = NULL, ?string $bundle = NULL, bool $require_all = TRUE): array;
/**
* Deletes the roles associated with a group type.
*/
public function removeRoles(string $entity_type_id, string $bundle_id);
}
