class RobotAccessController

Defines an access controller for the robot entity.

We set this class to be the access controller in Robot's entity annotation.

Hierarchy

  • class \Drupal\config_entity_example\RobotAccessController extends \Drupal\Core\Entity\EntityAccessControlHandler

Expanded class hierarchy of RobotAccessController

See also

\Drupal\config_entity_example\Entity\Robot

Related topics

File

modules/config_entity_example/src/RobotAccessController.php, line 19

Namespace

Drupal\config_entity_example
View source
class RobotAccessController extends EntityAccessControlHandler {
  
  /**
   * {@inheritdoc}
   */
  public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    // The $operation parameter tells you what sort of operation access is
    // being checked for.
    if ($operation == 'view') {
      return AccessResult::allowed();
    }
    // 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);
  }

}

Members

Title Sort descending Modifiers Object type Summary
RobotAccessController::checkAccess public function