You are here

class HiddenLanguagePermissions in Hidden Language 2.x

Same name and namespace in other branches
  1. 8 src/HiddenLanguagePermissions.php \Drupal\hidden_language\HiddenLanguagePermissions

Provides dynamic permissions of the filter module.

Hierarchy

Expanded class hierarchy of HiddenLanguagePermissions

File

src/HiddenLanguagePermissions.php, line 12

Namespace

Drupal\hidden_language
View source
class HiddenLanguagePermissions implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static();
  }

  /**
   * Returns an array of filter permissions.
   *
   * @return array
   */
  public function permissions() {
    $permissions = [];
    $languages = \Drupal::languageManager()
      ->getLanguages();
    foreach ($languages as $langcode => $language) {
      $permissions["access hidden language {$langcode}"] = [
        'title' => $this
          ->t('Access hidden language @language', [
          '@language' => $language
            ->getName(),
        ]),
        'description' => $this
          ->t('Access @language language when it is hidden.', [
          '@language' => $language
            ->getName(),
        ]),
      ];
    }
    return $permissions;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HiddenLanguagePermissions::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
HiddenLanguagePermissions::permissions public function Returns an array of filter permissions.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
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.