class RobotAccessController

Same name in other branches
  1. 3.x modules/config_entity_example/src/RobotAccessController.php \Drupal\config_entity_example\RobotAccessController
  2. 4.0.x modules/config_entity_example/src/RobotAccessController.php \Drupal\config_entity_example\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

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 $opereration 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