Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / media / src / MediaTypeAccessControlHandler.php
1 <?php
2
3 namespace Drupal\media;
4
5 use Drupal\Core\Access\AccessResult;
6 use Drupal\Core\Entity\EntityAccessControlHandler;
7 use Drupal\Core\Entity\EntityInterface;
8 use Drupal\Core\Session\AccountInterface;
9
10 /**
11  * Defines the access control handler for the "Media Type" entity type.
12  *
13  * @see \Drupal\media\Entity\MediaType
14  */
15 class MediaTypeAccessControlHandler extends EntityAccessControlHandler {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected $viewLabelOperation = TRUE;
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
26     if ($operation === 'view label') {
27       return AccessResult::allowedIfHasPermission($account, 'view media');
28     }
29     else {
30       return parent::checkAccess($entity, $operation, $account);
31     }
32   }
33
34 }