class DevelGeneratePermissions

Same name in other branches
  1. 4.x devel_generate/src/DevelGeneratePermissions.php \Drupal\devel_generate\DevelGeneratePermissions

Provides dynamic permissions of the filter module.

Hierarchy

Expanded class hierarchy of DevelGeneratePermissions

File

devel_generate/src/DevelGeneratePermissions.php, line 12

Namespace

Drupal\devel_generate
View source
class DevelGeneratePermissions implements ContainerInjectionInterface {
    use StringTranslationTrait;
    
    /**
     * The plugin manager.
     */
    protected DevelGeneratePluginManager $develGeneratePluginManager;
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container) : self {
        $instance = new self();
        $instance->develGeneratePluginManager = $container->get('plugin.manager.develgenerate');
        $instance->stringTranslation = $container->get('string_translation');
        return $instance;
    }
    
    /**
     * A permissions' callback.
     *
     * @see devel_generate.permissions.yml
     *
     * @return array
     *   An array of permissions for all plugins.
     */
    public function permissions() : array {
        $permissions = [];
        $devel_generate_plugins = $this->develGeneratePluginManager
            ->getDefinitions();
        foreach ($devel_generate_plugins as $plugin) {
            $permission = $plugin['permission'];
            $permissions[$permission] = [
                'title' => $this->t('@permission', [
                    '@permission' => $permission,
                ]),
            ];
        }
        return $permissions;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DevelGeneratePermissions::$develGeneratePluginManager protected property The plugin manager.
DevelGeneratePermissions::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
DevelGeneratePermissions::permissions public function A permissions' callback.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
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.