summaryrefslogtreecommitdiffstats
path: root/core/modules/overlay/lib/Drupal/overlay/Access/DismissMessageAccessCheck.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/overlay/lib/Drupal/overlay/Access/DismissMessageAccessCheck.php')
-rw-r--r--core/modules/overlay/lib/Drupal/overlay/Access/DismissMessageAccessCheck.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/modules/overlay/lib/Drupal/overlay/Access/DismissMessageAccessCheck.php b/core/modules/overlay/lib/Drupal/overlay/Access/DismissMessageAccessCheck.php
new file mode 100644
index 0000000..3c74bab
--- /dev/null
+++ b/core/modules/overlay/lib/Drupal/overlay/Access/DismissMessageAccessCheck.php
@@ -0,0 +1,43 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\overlay\Access\DismissMessageAccessCheck
+ */
+
+namespace Drupal\overlay\Access;
+
+use Drupal\Core\Access\AccessCheckInterface;
+use Symfony\Component\Routing\Route;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Provides an access check for overlay user dismiss message routes.
+ */
+class DismissMessageAccessCheck implements AccessCheckInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function applies(Route $route) {
+ return array_key_exists('_access_overlay_dismiss_message', $route->getRequirements());
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function access(Route $route, Request $request) {
+ $account = $request->attributes->get('account');
+ if (!user_access('access overlay', $account)) {
+ return static::DENY;
+ }
+ // It's unlikely, but possible that "access overlay" permission is granted
+ // to the anonymous role. In this case, we do not display the message to
+ // disable the overlay, so there is nothing to dismiss.
+ if (!$account->id()) {
+ return static::DENY;
+ }
+ return static::ALLOW;
+ }
+
+}