Skip to content

Instantly share code, notes, and snippets.

@chriscalip
Created May 4, 2017 01:10
Show Gist options
  • Save chriscalip/771523a4564cb93153ec52c4557e4025 to your computer and use it in GitHub Desktop.
Save chriscalip/771523a4564cb93153ec52c4557e4025 to your computer and use it in GitHub Desktop.
Sample Drupal 8 Feature documentation for situations where codebase is all over the place.

Capacitype Collection Feature List.

Description

Collection nodes are visible only to the author node and users with permission "bypass node access"

Feature Manifest

  • File capacitype_collection/capacitype_collection.module Hook function capacitype_collection_node_access() responsible for implementing feature.

Description

Provides a publicly viewable url for a collection node.

Current user flow.

At event Author clicks at a collection share link, shows a modal dialog popup "Share" thats lists:

  • Email
  • Facebook
  • Twitter
  • Link to page

All lists items are "Call to action" links having the publicly viewable url of a collection node.

Feature Manifest

  • File capacitype_collection/capacitype_collection.install Hook function capacitype_collection_schema(), adds backend table holding publicly viewable url parts (nid,uid,pass,etc..)
  • File capacitype_collection/capacitype_collection.routing.yml declares custom route capacitype_collection.public_view aka the publicly viewable url for a collection node.
  • File capacitype_collection/capacitype_collection.module Hook function capacitype_collection_node_presave(), responsible for adding a publicly viewable url database record.
  • File capacitype_collection/capacitype_collection.drush.inc Hook drush_capacitype_collection_c5cc_create_public_collection_urls(),adds script drush c5cc-create-public-collection-urls, this script backfills any collection nodes without a publicly viewable url.
  • File capacitype_collection/src/Controller/ShareCollectionController method ShareCollectionController::publicAccess handles access control for route capacitype_collection.public_view
  • File capacitype_collection/src/Controller/ShareCollectionController method ShareCollectionController::publicView view handler for route capacitype_collection.public_view
  • File themes/custom/capacitype/templates/content/node--collection--full.html.twig section shareable collection integration adds modal dialog javascripts & sharelink to template.
  • File themes/custom/capacitype/capacitype.theme function capacitype_preprocess_node section shareable collection integration adds variable shareable_collection_link for template use in node--collection--full.html.twig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment