cloud-8.x-2.0-beta1/modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/NetworkInterfaceAccessControlHandler.php

modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/NetworkInterfaceAccessControlHandler.php
<?php

namespace Drupal\aws_cloud\Controller\Ec2;

use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\cloud\Traits\AccessCheckTrait;

/**
 * Access controller for the NetworkInterface entity.
 *
 * @see \Drupal\aws_cloud\Entity\Ec2\NetworkInterface\Entity\NetworkInterface.
 */
class NetworkInterfaceAccessControlHandler extends EntityAccessControlHandler {

  use AccessCheckTrait;

  /**
   * {@inheritdoc}
   */
  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {

    switch ($operation) {
      case 'view':
        return $this->allowedIfCanAccessCloudConfigWithOwner(
          $entity,
          $account,
          'view own aws cloud network interface',
          'view any aws cloud network interface'
        );

      case 'update':
      case 'edit':
        return $this->allowedIfCanAccessCloudConfigWithOwner(
          $entity,
          $account,
          'edit own aws cloud network interface',
          'edit any aws cloud network interface'
        );

      case 'delete':
        return $this->allowedIfCanAccessCloudConfigWithOwner(
          $entity,
          $account,
          'delete own aws cloud network interface',
          'delete any aws cloud network interface'
        );
    }
    // Unknown operation, no opinion.
    return AccessResult::neutral();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc