class FeedsPermissions in Feeds 8.3
Defines a class containing permission callbacks.
Hierarchy
- class \Drupal\feeds\FeedsPermissions uses StringTranslationTrait
 
Expanded class hierarchy of FeedsPermissions
File
- src/
FeedsPermissions.php, line 12  
Namespace
Drupal\feedsView source
class FeedsPermissions {
  use StringTranslationTrait;
  /**
   * Returns an array of content permissions.
   *
   * @return array
   *   Permissions for operations on feeds.
   */
  public function contentPermissions() {
    return [
      'access feed overview' => [
        'title' => $this
          ->t('Access the Feed overview page'),
        'description' => $this
          ->t('Get an overview of <a href=":url">all feeds</a>.', [
          ':url' => Url::fromRoute('feeds.admin'),
        ]),
      ],
    ];
  }
  /**
   * Returns an array of feeds type permissions.
   *
   * @return array
   *   Permissions for operations on feed types.
   */
  public function feedTypePermissions() {
    $perms = [];
    // Generate feeds permissions for all feeds types.
    foreach (FeedType::loadMultiple() as $type) {
      $perms += $this
        ->buildPermissions($type);
    }
    return $perms;
  }
  /**
   * Builds a standard list of feeds permissions for a given type.
   *
   * @param \Drupal\feeds\Entity\FeedType $feed_type
   *   The feed type object.
   *
   * @return array
   *   An array of permission names and descriptions.
   */
  protected function buildPermissions(FeedType $feed_type) {
    $args = [
      '%name' => $feed_type
        ->label(),
    ];
    $id = $feed_type
      ->id();
    return [
      "view {$id} feeds" => [
        'title' => $this
          ->t('%name: View feeds', $args),
      ],
      "create {$id} feeds" => [
        'title' => $this
          ->t('%name: Create new feeds', $args),
      ],
      "update {$id} feeds" => [
        'title' => $this
          ->t('%name: Update existing feeds', $args),
      ],
      "delete {$id} feeds" => [
        'title' => $this
          ->t('%name: Delete feeds', $args),
      ],
      "import {$id} feeds" => [
        'title' => $this
          ->t('%name: Import feeds', $args),
      ],
      "schedule_import {$id} feeds" => [
        'title' => $this
          ->t('%name: Import feeds in background', $args),
      ],
      "clear {$id} feeds" => [
        'title' => $this
          ->t('%name: Delete feed items', $args),
      ],
      "unlock {$id} feeds" => [
        'title' => $this
          ->t('%name: Unlock feeds', $args),
        'description' => $this
          ->t('If a feed importation breaks for some reason, users with this permission can unlock it.'),
      ],
    ];
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            FeedsPermissions:: | 
                  protected | function | Builds a standard list of feeds permissions for a given type. | |
| 
            FeedsPermissions:: | 
                  public | function | Returns an array of content permissions. | |
| 
            FeedsPermissions:: | 
                  public | function | Returns an array of feeds type permissions. | |
| 
            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. |