Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / service / request-policy.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/service/request-policy.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/service/request-policy.twig
new file mode 100644 (file)
index 0000000..3162955
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\{{ machine_name }}\PageCache;
+
+use Drupal\Core\PageCache\RequestPolicyInterface;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * A policy allowing to bypass cache for requests with 'no-cache' parameter.
+ *
+ * Example: https://example.com/node?no-cache.
+ */
+class {{ class }} implements RequestPolicyInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function check(Request $request) {
+    if (!is_null($request->get('no-cache'))) {
+      return self::DENY;
+    }
+  }
+
+}