Version 1
[yaffs-website] / web / core / modules / book / tests / modules / book_breadcrumb_test / book_breadcrumb_test.module
diff --git a/web/core/modules/book/tests/modules/book_breadcrumb_test/book_breadcrumb_test.module b/web/core/modules/book/tests/modules/book_breadcrumb_test/book_breadcrumb_test.module
new file mode 100644 (file)
index 0000000..526da71
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * @file
+ * Test module for testing the book module breadcrumb.
+ */
+
+use Drupal\Core\Access\AccessResultForbidden;
+use Drupal\Core\Access\AccessResultNeutral;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\node\NodeInterface;
+
+/**
+ * Implements hook_node_access().
+ */
+function book_breadcrumb_test_node_access(NodeInterface $node, $operation, AccountInterface $account) {
+  $config = \Drupal::config('book_breadcrumb_test.settings');
+  if ($config->get('hide') && $node->getTitle() == "you can't see me" && $operation == 'view') {
+    $access = new AccessResultForbidden();
+  }
+  else {
+    $access = new AccessResultNeutral();
+  }
+  $access->addCacheableDependency($config);
+  $access->addCacheableDependency($node);
+  return $access;
+}