Returns an array of entity_clone_extras permissions.

Return value

array The permission list.

1 string reference to 'EntityCloneExtrasPermissions::permissions'
entity_clone_extras.permissions.yml dans modules/entity_clone_extras/entity_clone_extras.permissions.yml
modules/entity_clone_extras/entity_clone_extras.permissions.yml

Fichier

modules/entity_clone_extras/src/EntityCloneExtrasPermissions.php, line 70

Classe

EntityCloneExtrasPermissions
Provides dynamic permissions of the entity_clone module.

Namespace

Drupal\entity_clone_extras

Code

public function permissions() {
    $permissions = [];
    // Fetch all available content types.
    $content_types = $this->entityTypeManager
        ->getStorage('node_type')
        ->loadMultiple();
    foreach ($content_types as $key => $type) {
        // Add a permission to clone each content type.
        $permissions['clone ' . $key . ' node entities'] = $this->translationManager
            ->translate('Clone all <em>@label</em> node entities', [
            '@label' => $type->label(),
        ]);
    }
    // Support media entities when media module is installed.
    if ($this->moduleHandler
        ->moduleExists('media')) {
        // Fetch all available media types.
        $media_types = $this->entityTypeManager
            ->getStorage('media_type')
            ->loadMultiple();
        foreach ($media_types as $key => $type) {
            // Add a permission to clone each media type.
            $permissions['clone ' . $key . ' media entities'] = $this->translationManager
                ->translate('Clone all <em>@label</em> media entities', [
                '@label' => $type->label(),
            ]);
        }
    }
    return $permissions;
}