You are here

class MenuAdminPerMenuPermissions in Menu Admin per Menu 8

Menu Admin Per Menu Permissions class.

Manages getting a list of menus, and generating a list of permissions per menu.

Hierarchy

Expanded class hierarchy of MenuAdminPerMenuPermissions

1 file declares its use of MenuAdminPerMenuPermissions
MenuAdminPerMenuPermissionsTest.php in tests/src/Kernel/MenuAdminPerMenuPermissionsTest.php

File

src/MenuAdminPerMenuPermissions.php, line 15

Namespace

Drupal\menu_admin_per_menu
View source
class MenuAdminPerMenuPermissions {
  use StringTranslationTrait;

  /**
   * Returns an array of existing menus on site.
   *
   * @return array
   *   Array of existing menus on the site.
   */
  protected function getExistingMenus() {
    return menu_ui_get_menus();
  }

  /**
   * Returns an array of menu_admin_per_menu permissions.
   *
   * @return array
   *   Array of permissions associated with menus.
   */
  public function permissions() {
    $permissions = [];
    $menus = $this
      ->getExistingMenus();
    foreach ($menus as $name => $title) {
      $permission = 'administer ' . $name . ' menu items';
      $permissions[$permission] = [
        'title' => $this
          ->t('Administer <em>@menu</em> menu items', [
          '@menu' => $title,
        ]),
      ];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MenuAdminPerMenuPermissions::getExistingMenus protected function Returns an array of existing menus on site.
MenuAdminPerMenuPermissions::permissions public function Returns an array of menu_admin_per_menu permissions.
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.