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
- class \Drupal\menu_admin_per_menu\MenuAdminPerMenuPermissions uses StringTranslationTrait
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_menuView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MenuAdminPerMenuPermissions:: |
protected | function | Returns an array of existing menus on site. | |
MenuAdminPerMenuPermissions:: |
public | function | Returns an array of menu_admin_per_menu permissions. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |