You are here

public function CommentFlagType::actionPermissions in Flag 8.4

Returns the permissions available to this flag type.

Parameters

\Drupal\flag\FlagInterface $flag: The flag object.

Return value

array An array of permissions.

Overrides EntityFlagType::actionPermissions

File

src/Plugin/Flag/CommentFlagType.php, line 31

Class

CommentFlagType
Provides a flag type for comments.

Namespace

Drupal\flag\Plugin\Flag

Code

public function actionPermissions(FlagInterface $flag) {
  $permissions = parent::actionPermissions($flag);
  if (!empty($this->configuration['extra_permissions'])) {
    foreach ($this->configuration['extra_permissions'] as $option) {
      switch ($option) {

        // The 'owner' case is handled by the parent method.
        case 'parent_owner':

          // Define additional permissions.
          $permissions['flag ' . $flag
            ->id() . ' comments on own parent entities'] = [
            'title' => $this
              ->t('Flag %flag_title comments on own parent entities', [
              '%flag_title' => $flag
                ->label(),
            ]),
          ];
          $permissions['unflag ' . $flag
            ->id() . ' comments on own parent entities'] = [
            'title' => $this
              ->t('Unflag %flag_title on own parent entities', [
              '%flag_title' => $flag
                ->label(),
            ]),
          ];
          $permissions['flag ' . $flag
            ->id() . ' comments on other parent entities'] = [
            'title' => $this
              ->t("Flag %flag_title on others' parent entities", [
              '%flag_title' => $flag
                ->label(),
            ]),
          ];
          $permissions['unflag ' . $flag
            ->id() . ' comments on other parent entities'] = [
            'title' => $this
              ->t("Unflag %flag_title on others' parent entities", [
              '%flag_title' => $flag
                ->label(),
            ]),
          ];
          break;
      }
    }
  }
  return $permissions;
}