class Permissions in Search API Saved Searches 8
Provides permissions of the search_api_autocomplete module.
Hierarchy
- class \Drupal\search_api_saved_searches\Permissions implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 13
Namespace
Drupal\search_api_saved_searchesView source
class Permissions implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The saved search type storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$object = new static();
$storage = $container
->get('entity_type.manager')
->getStorage('search_api_saved_search_type');
$object
->setStorage($storage);
$object
->setStringTranslation($container
->get('string_translation'));
return $object;
}
/**
* Retrieves the saved search type storage.
*
* @return \Drupal\Core\Entity\EntityStorageInterface
* The saved search type storage.
*/
public function getStorage() {
return $this->storage ?: \Drupal::entityTypeManager()
->getStorage('search_api_saved_search_type');
}
/**
* Sets the saved search type storage.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The new saved search type storage.
*
* @return $this
*/
public function setStorage(EntityStorageInterface $storage) {
$this->storage = $storage;
return $this;
}
/**
* Returns a list of permissions, one per configured saved search type.
*
* @return array[]
* A list of permission definitions, keyed by permission machine name.
*/
public function bySavedSearchType() {
$perms = [];
foreach ($this
->getStorage()
->loadMultiple() as $id => $type) {
$args = [
'%type' => $type
->label(),
];
$perms['use ' . $id . ' search_api_saved_searches'] = [
'title' => $this
->t('Use saved searches of type %type', $args),
];
}
return $perms;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Permissions:: |
protected | property | The saved search type storage. | |
Permissions:: |
public | function | Returns a list of permissions, one per configured saved search type. | |
Permissions:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Permissions:: |
public | function | Retrieves the saved search type storage. | |
Permissions:: |
public | function | Sets the saved search type storage. | |
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. |