You are here

QuickNodeClonePermissions.php in Quick Node Clone 8

File

src/QuickNodeClonePermissions.php
View source
<?php

namespace Drupal\quick_node_clone;

use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\node\Entity\NodeType;

/**
 * Module permissions.
 */
class QuickNodeClonePermissions {
  use StringTranslationTrait;

  /**
   * Returns an array of permissions.
   *
   * @return array
   *   The permissions.
   *
   * @see \Drupal\user\PermissionHandlerInterface::getPermissions()
   */
  public function cloneTypePermissions() {
    $perms = [];

    // Generate node permissions for all node types.
    foreach (NodeType::loadMultiple() as $type) {
      $type_id = $type
        ->id();
      $type_params = [
        '%type' => $type
          ->label(),
      ];
      $perms += [
        "clone {$type_id} content" => [
          'title' => $this
            ->t('%type: clone content', $type_params),
        ],
      ];
    }
    return $perms;
  }

}

Classes

Namesort descending Description
QuickNodeClonePermissions Module permissions.