class Permissions in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/Permissions.php \Drupal\entity_browser\Permissions
Generates routes for entity browsers.
Hierarchy
- class \Drupal\entity_browser\Permissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 13
Namespace
Drupal\entity_browserView source
class Permissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The entity browser storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $browserStorage;
/**
* Constructs Permissions object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->browserStorage = $entity_type_manager
->getStorage('entity_browser');
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('entity_type.manager'));
}
/**
* Dynamically set permissions for entity browsers with routes.
*/
public function permissions() {
$permissions = [];
/** @var \Drupal\entity_browser\EntityBrowserInterface[] $browsers */
$browsers = $this->browserStorage
->loadMultiple();
foreach ($browsers as $browser) {
if ($browser
->route()) {
$permissions['access ' . $browser
->id() . ' entity browser pages'] = [
'title' => $this
->t('Access @name pages', [
'@name' => $browser
->label(),
]),
'description' => $this
->t('Access pages that %browser uses to operate.', [
'%browser' => $browser
->label(),
]),
];
}
}
return $permissions;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
protected | property | The entity browser storage. | |
Permissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Permissions:: |
public | function | Dynamically set permissions for entity browsers with routes. | |
Permissions:: |
public | function | Constructs Permissions object. | |
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. |