Version 1
[yaffs-website] / web / modules / contrib / environment_indicator / src / EnvironmentIndicatorAccessControlHandler.php
diff --git a/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorAccessControlHandler.php b/web/modules/contrib/environment_indicator/src/EnvironmentIndicatorAccessControlHandler.php
new file mode 100644 (file)
index 0000000..6a814f6
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace Drupal\environment_indicator;
+
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Entity\EntityAccessControlHandler;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Defines an access controller for the environment entity.
+ *
+ * @see \Drupal\environment_indicator\Plugin\Core\Entity\EnvironmentIndicator.
+ */
+class EnvironmentIndicatorAccessControlHandler extends EntityAccessControlHandler {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
+    return AccessResult::allowedIf($account->hasPermission('administer environment indicator settings'));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
+    return AccessResult::allowedIf($account->hasPermission('administer environment indicator settings'));
+  }
+
+}