Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / page_attachments.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/page_attachments.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/page_attachments.twig
new file mode 100644 (file)
index 0000000..3468151
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * Implements hook_page_attachments().
+ */
+function {{ machine_name }}_page_attachments(array &$attachments) {
+  // Unconditionally attach an asset to the page.
+  $attachments['#attached']['library'][] = 'core/domready';
+
+  // Conditionally attach an asset to the page.
+  if (!\Drupal::currentUser()->hasPermission('may pet kittens')) {
+    $attachments['#attached']['library'][] = 'core/jquery';
+  }
+}