og-8.x-1.x-dev/src/Event/DefaultRoleEventInterface.php

src/Event/DefaultRoleEventInterface.php
<?php

declare(strict_types=1);

namespace Drupal\og\Event;

use Drupal\og\OgRoleInterface;

/**
 * Interface for DefaultRoleEvent classes.
 *
 * This event allows implementing modules to provide their own default roles or
 * alter existing default roles that are provided by other modules.
 */
interface DefaultRoleEventInterface extends \ArrayAccess, \IteratorAggregate {

  /**
   * The event name.
   */
  const EVENT_NAME = 'og.default_role';

  /**
   * Returns a single default role.
   *
   * @throws \InvalidArgumentException
   *   Thrown when the role with the given name does not exist.
   */
  public function getRole(string $name): ?OgRoleInterface;

  /**
   * Returns all the default role names.
   *
   * @return array<array-key, \Drupal\og\OgRoleInterface>
   *   An associative array of default role properties, keyed by role name.
   */
  public function getRoles(): array;

  /**
   * Adds a default role.
   *
   * This should be an unsaved entity that doesn't have the group entity type
   * and bundle IDs set.
   *
   * @throws \InvalidArgumentException
   *   Thrown when the role that is added already exists.
   */
  public function addRole(OgRoleInterface $role): void;

  /**
   * Adds multiple default roles.
   *
   * @param \Drupal\og\OgRoleInterface[] $roles
   *   An array of OgRole entities to add. These should be unsaved entities that
   *   don't have the group entity type and bundle IDs set.
   */
  public function addRoles(array $roles): void;

  /**
   * Sets a default role.
   *
   * This should be an unsaved entity that doesn't have the group entity type
   * and bundle IDs set.
   *
   * @throws \InvalidArgumentException
   *   Thrown when the role name is empty, or when the 'label' property is
   *   missing.
   */
  public function setRole(OgRoleInterface $role): void;

  /**
   * Sets multiple default roles.
   *
   * @param \Drupal\og\OgRoleInterface[] $roles
   *   An array of OgRole entities to set. These should be unsaved entities that
   *   don't have the group entity type and bundle IDs set.
   */
  public function setRoles(array $roles): void;

  /**
   * Deletes the given default role.
   */
  public function deleteRole(string $name): void;

  /**
   * Returns whether the given role exists by name.
   */
  public function hasRole(string $name): bool;

}

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

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