pm-4.1.x-dev/modules/pm_epic/src/PmEpicAccessControlHandler.php

modules/pm_epic/src/PmEpicAccessControlHandler.php
<?php

namespace Drupal\pm_epic;

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

/**
 * Defines the access control handler for the pm epic entity type.
 */
class PmEpicAccessControlHandler extends EntityAccessControlHandler {

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

    switch ($operation) {
      case 'view':
        return AccessResult::allowedIfHasPermission($account, 'view pm epic');

      case 'update':
        return AccessResult::allowedIfHasPermissions(
          $account,
          ['edit pm epic', 'administer pm epic'],
          'OR',
        );

      case 'delete':
        return AccessResult::allowedIfHasPermissions(
          $account,
          ['delete pm epic', 'administer pm epic'],
          'OR',
        );

      default:
        // No opinion.
        return AccessResult::neutral();
    }

  }

  /**
   * {@inheritdoc}
   */
  protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
    return AccessResult::allowedIfHasPermissions(
      $account,
      ['create pm epic', 'administer pm epic'],
      'OR',
    );
  }

}

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

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