You are here

class EventPermissions in Booking and Availability Management Tools for Drupal 8

Hierarchy

Expanded class hierarchy of EventPermissions

File

modules/bat_event/src/EventPermissions.php, line 18
Contains \Drupal\bat_event\EventPermissions.

Namespace

Drupal\bat_event
View source
class EventPermissions implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a new FilterPermissions instance.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
   *   The entity manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_manager) {
    $this->entityTypeManager = $entity_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('entity_type.manager'));
  }

  /**
   * Returns an array of filter permissions.
   *
   * @return array
   */
  public function permissions() {
    $permissions = [];
    foreach (bat_event_get_types() as $bundle_name => $bundle_info) {
      $permissions['view calendar data for any ' . $bundle_name . ' event'] = [
        'title' => $this
          ->t('View calendar data for any %bundle @entity_type', [
          '@entity_type' => 'events',
          '%bundle' => $bundle_info
            ->label(),
        ]),
      ];
    }
    return $permissions + bat_entity_access_permissions('bat_event');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EventPermissions::$entityTypeManager protected property The entity manager.
EventPermissions::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
EventPermissions::permissions public function Returns an array of filter permissions.
EventPermissions::__construct public function Constructs a new FilterPermissions instance.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.