--- /dev/null
+<?php
+
+namespace Drupal\{{ machine_name }};
+
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Entity\EntityAccessControlHandler;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Defines the access control handler for the {{ entity_type_label|lower }} entity type.
+ */
+class {{ class_prefix }}AccessControlHandler extends EntityAccessControlHandler {
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
+
+ switch ($operation) {
+ case 'view':
+ return AccessResult::allowedIfHasPermission($account, 'view {{ entity_type_label|lower }}');
+
+ case 'update':
+ return AccessResult::allowedIfHasPermissions($account, ['edit {{ entity_type_label|lower }}', 'administer {{ entity_type_label|lower }}'], 'OR');
+
+ case 'delete':
+ return AccessResult::allowedIfHasPermissions($account, ['delete {{ entity_type_label|lower }}', 'administer {{ entity_type_label|lower }}'], 'OR');
+
+ default:
+ // No opinion.
+ return AccessResult::neutral();
+ }
+
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
+ return AccessResult::allowedIfHasPermissions($account, ['create {{ entity_type_label|lower }}', 'administer {{ entity_type_label|lower }}'], 'OR');
+ }
+
+}