class FlagListsPermissionHandler in Flag Lists 4.0.x
Hierarchy
- class \Drupal\user\PermissionHandler implements PermissionHandlerInterface uses StringTranslationTrait
- class \Drupal\flag_lists\Permissions\FlagListsPermissionHandler uses StringTranslationTrait
Expanded class hierarchy of FlagListsPermissionHandler
1 string reference to 'FlagListsPermissionHandler'
1 service uses FlagListsPermissionHandler
File
- src/
Permissions/ FlagListsPermissionHandler.php, line 15
Namespace
Drupal\flag_lists\PermissionsView source
class FlagListsPermissionHandler extends PermissionHandler {
use StringTranslationTrait;
/**
* The Flag Lists Service.
*
* @var \Drupal\flag_lists\FlagListsServiceInterface
*/
protected $flagListsService;
/**
* Constructs a new PermissionHandler.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation.
* @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver
* The controller resolver.
* @param \Drupal\flag_lists\FlagListsServiceInterface $flag_lists_service
* The Flag Lists Service.
*/
public function __construct(ModuleHandlerInterface $module_handler, TranslationInterface $string_translation, ControllerResolverInterface $controller_resolver, FlagListsServiceInterface $flag_lists_service) {
parent::__construct($module_handler, $string_translation, $controller_resolver);
$this->flagListsService = $flag_lists_service;
}
/**
* {@inheritdoc}
*/
public function getPermissions() {
$all_permissions = $this
->buildPermissionsYaml();
// Remove the possible long list of unused flag permissions
// due to the flag lists module.
$flagLists = $this->flagListsService
->getAllFlaggingCollections();
foreach ($flagLists as $flagList) {
$flag = 'flag ' . $flagList
->getRelatedFlag()
->id();
$unflag = 'unflag ' . $flagList
->getRelatedFlag()
->id();
unset($all_permissions[$flag]);
unset($all_permissions[$unflag]);
}
// Check for access for the used template as well.
$flagTemplates = $this->flagListsService
->getAllFlagForList();
foreach ($flagTemplates as $flagTemplate) {
// Do we really want to remove the templates from
// the possibility of setting them separately?
$flag = 'flag ' . $flagTemplate
->id();
$unflag = 'unflag ' . $flagTemplate
->id();
unset($all_permissions[$flag]);
unset($all_permissions[$unflag]);
}
return $this
->sortPermissions($all_permissions);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlagListsPermissionHandler:: |
protected | property | The Flag Lists Service. | |
FlagListsPermissionHandler:: |
public | function |
Gets all available permissions. Overrides PermissionHandler:: |
|
FlagListsPermissionHandler:: |
public | function |
Constructs a new PermissionHandler. Overrides PermissionHandler:: |
|
PermissionHandler:: |
protected | property | The controller resolver. | |
PermissionHandler:: |
protected | property | The module handler. | |
PermissionHandler:: |
protected | property | The YAML discovery class to find all .permissions.yml files. | |
PermissionHandler:: |
protected | function | Builds all permissions provided by .permissions.yml files. | |
PermissionHandler:: |
protected | function | Returns all module names. | |
PermissionHandler:: |
protected | function | Gets the YAML discovery. | |
PermissionHandler:: |
public | function |
Determines whether a module provides some permissions. Overrides PermissionHandlerInterface:: |
|
PermissionHandler:: |
protected | function | Sorts the given permissions by provider name and title. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |