You are here

PresetAccessController.php in Video 8.2

File

modules/video_transcode/src/PresetAccessController.php
View source
<?php

namespace Drupal\video_transcode;

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

/**
 * Defines an access controller for the preset entity.
 *
 * We set this class to be the access controller in Preset's entity annotation.
 *
 * @see \Drupal\video_transcode\Entity\Preset
 *
 * @ingroup config_entity_example
 */
class PresetAccessController extends EntityAccessControlHandler {

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

    // The $opereration parameter tells you what sort of operation access is
    // being checked for.
    if ($operation == 'view') {
      return TRUE;
    }

    // Other than the view operation, we're going to be insanely lax about
    // access. Don't try this at home!
    return parent::checkAccess($entity, $operation, $account);
  }

}

Classes

Namesort descending Description
PresetAccessController Defines an access controller for the preset entity.