ThunderTermAccessControlHandler.php in Thunder 8.4
Same filename and directory in other branches
- 8.5 modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.php
- 8.2 modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.php
- 8.3 modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.php
- 6.2.x modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.php
- 6.0.x modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.php
- 6.1.x modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.php
Namespace
Drupal\thunder_taxonomyFile
modules/thunder_taxonomy/src/ThunderTermAccessControlHandler.phpView source
<?php
namespace Drupal\thunder_taxonomy;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\taxonomy\TermAccessControlHandler;
/**
* Defines the access control handler for the taxonomy term entity type.
*
* @see \Drupal\taxonomy\Entity\Term
*/
class ThunderTermAccessControlHandler extends TermAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
// Check for status and set 'published' or 'unpublished'.
$status = $entity->status->value ? 'published' : 'unpublished';
return AccessResult::allowedIf($account
->hasPermission('access content') && $account
->hasPermission('view ' . $status . ' terms in ' . $entity
->bundle()));
default:
return parent::checkAccess($entity, $operation, $account);
}
}
}
Classes
Name | Description |
---|---|
ThunderTermAccessControlHandler | Defines the access control handler for the taxonomy term entity type. |