og-8.x-1.x-dev/src/OgRoleInterface.php

src/OgRoleInterface.php
<?php

declare(strict_types=1);

namespace Drupal\og;

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\user\RoleInterface;

/**
 * Provides an interface defining an OG user role entity.
 */
interface OgRoleInterface extends RoleInterface {

  /**
   * The role name of the group non-member.
   */
  const ANONYMOUS = 'non-member';

  /**
   * The role name of the group member.
   */
  const AUTHENTICATED = 'member';

  /**
   * The role name of the group administrator.
   */
  const ADMINISTRATOR = 'administrator';

  /**
   * Role type for required roles.
   *
   * This is intended for the 'non-member' and 'member' roles. These cannot be
   * changed or deleted.
   */
  const ROLE_TYPE_REQUIRED = 'required';

  /**
   * Role type for standard roles that are editable and deletable.
   */
  const ROLE_TYPE_STANDARD = 'standard';

  /**
   * Sets the ID of the role.
   */
  public function setId(string $id): static;

  /**
   * Returns the label.
   */
  public function getLabel(): string;

  /**
   * Sets the label.
   */
  public function setLabel(string $label): static;

  /**
   * Returns the group type.
   */
  public function getGroupType(): ?string;

  /**
   * Sets the group type.
   */
  public function setGroupType(string $group_type): static;

  /**
   * Returns the group bundle.
   */
  public function getGroupBundle(): string;

  /**
   * Sets the group bundle.
   */
  public function setGroupBundle(string $group_bundle): static;

  /**
   * Returns the role type.
   *
   * @return string
   *   The role type. One of OgRoleInterface::ROLE_TYPE_REQUIRED or
   *   OgRoleInterface::ROLE_TYPE_STANDARD.
   */
  public function getRoleType(): string;

  /**
   * Sets the role type.
   *
   * @param string $role_type
   *   The role type to set. One of OgRoleInterface::ROLE_TYPE_REQUIRED or
   *   OgRoleInterface::ROLE_TYPE_STANDARD.
   *
   * @return $this
   *
   * @throws \InvalidArgumentException
   *   Thrown when an invalid role type is given.
   */
  public function setRoleType(string $role_type): static;

  /**
   * Returns whether or not a role can be changed.
   *
   * This will return FALSE for all roles except the default roles 'non-member'
   * and 'member'.
   */
  public function isLocked(): bool;

  /**
   * Returns the role name.
   *
   * A role's name consists of the portion of the ID after the group entity type
   * ID and the group bundle ID.
   */
  public function getName(): ?string;

  /**
   * Sets the role name.
   */
  public function setName(string $name): static;

  /**
   * Returns the role represented by the given group and role name.
   */
  public static function loadByGroupAndName(ContentEntityInterface $group, string $name): ?static;

  /**
   * Returns the roles that are associated with the given group type and bundle.
   */
  public static function loadByGroupType(string $group_entity_type_id, string $group_bundle_id): array;

  /**
   * Get a role by the group's bundle and role name.
   */
  public static function getRole(string $entity_type_id, string $bundle, string $role_name): ?static;

  /**
   * Returns if this is a default role which is required and cannot be deleted.
   */
  public function isRequired(): bool;

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc