class ViewJobAccess

Access plugin that checks multiple permissions.

Plugin annotation


@ViewsAccess(
  id = "tmgmt_job",
  title = @Translation("View translation jobs")
)

Hierarchy

  • class \Drupal\tmgmt\Plugin\views\access\ViewJobAccess extends \Drupal\views\Plugin\views\access\AccessPluginBase

Expanded class hierarchy of ViewJobAccess

File

src/Plugin/views/access/ViewJobAccess.php, line 17

Namespace

Drupal\tmgmt\Plugin\views\access
View source
class ViewJobAccess extends AccessPluginBase {

  /**
   * List of permissions that allow view access.
   *
   * @var array
   */
  protected $permissions = [
    'administer tmgmt',
    'create translation jobs',
    'accept translation jobs',
  ];

  /**
   * {@inheritdoc}
   */
  public function summaryTitle() {
    return $this
      ->t('Job view access');
  }

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account) {
    foreach ($this->permissions as $permission) {
      if ($account
        ->hasPermission($permission)) {
        return TRUE;
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function alterRouteDefinition(Route $route) {
    $route
      ->setRequirement('_permission', (string) implode('+', $this->permissions));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ViewJobAccess::$permissions protected property List of permissions that allow view access.
ViewJobAccess::access public function
ViewJobAccess::alterRouteDefinition public function
ViewJobAccess::summaryTitle public function