l10n_server-2.x-dev/l10n_server/src/Entity/AccessControlHandler/L10nServerReleaseAccessControlHandler.php

l10n_server/src/Entity/AccessControlHandler/L10nServerReleaseAccessControlHandler.php
<?php

namespace Drupal\l10n_server\Entity\AccessControlHandler;

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 l10n server project entity type.
 */
class L10nServerReleaseAccessControlHandler extends EntityAccessControlHandler {

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

    switch ($operation) {
      case 'view':
        return AccessResult::allowedIfHasPermission($account, 'view l10n server release');

      case 'update':
        return AccessResult::allowedIfHasPermissions(
          $account,
          ['edit l10n server release', 'administer l10n server release'],
          'OR',
        );

      case 'delete':
        return AccessResult::allowedIfHasPermissions(
          $account,
          ['delete l10n server release', 'administer l10n server release'],
          'OR',
        );

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

  }

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

}

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

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