27
Outgrowing Content Types: Building Custom Entities DrupalGovCon July 24, 2019

Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Outgrowing Content Types: Building Custom Entities

DrupalGovCon July 24, 2019

Page 2: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

[email protected] @nJim

Page 3: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Four Kitchens builds websites and apps for organizations that depend on large-scale or unconventional content.

Page 4: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

What is an entity?

Page 5: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Drupal 6● Added a DB abstraction layer.

● CCK module extended content types.

● The idea of fieldable-content pushed us toward making everything a node.

Page 6: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Drupal 7● Intentionally an abstract term, entities are

objects that are used for persistent storage of content and configuration information

● Entities become a stdObject in core.

● Nodes, Taxonomy, Users, others are fieldable.

Page 7: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Drupal 8● Entities are defined with typed objects.

● Interfaces enforce consistent implementations.

● Includes Content and Configuration entities. While both are relevant, this presentation will focus on content entities.

Page 8: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Core & Contrib Entities

Page 9: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Core EntitiesEntity Bundle Module Usage

Content Content Type node Traditional content page.

User none user Access accounts.

Custom Block Block Type custom_block Ancillary content items.

Taxonomy Term Vocabulary taxonomy Tagging and feeds.

Media Media Type media Multimedia and metadata.

File none file Files and metadata.

Additional core entities include: Comment, Contact Form, Menu Link Content, and Shortcut among others.

Page 10: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Contrib EntitiesEntity Module Usage

Paragraph paragraph Content components.

Webforms / Submissions webform Form builder / storage.

Pathauto Patterns pathauto URL alias definitions.

Metatag Defaults metatag Per content metatag settings.

Redirect redirect Redirect (4xx response) management.

Group group Define entity collections.

Page 11: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Why create custom entities?● Reducing Overhead

● Optimizing Builds

● Presentation

● Performance

● Access

● Storage

Page 12: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #1: Reducing Overhead

When content types are too big.

Page 13: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #1: Reducing Overhead

When content types are too big.Raspberry Pi Data Feed● New temperature reading

every minute via API.● Logs include temperature

and timestamp only.● No need for traditional

editorial controls.

Page 14: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #2: Optimizing

When content types are too small.Regional Microsites● Non-Profit is adding sites

for each metro area.● Organization wide content

will mix with local.● Stakeholders value

consistency between sites.

Page 15: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #3: Presentation

Presenting customized editorial experiences.Timecards● Unique access for Staff,

Manager, and Finance.● Different forms based user

role and workflow status.● All changes logged for

financial integrity.

Page 16: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #4: Access

Defining unique access controls & permissions.Ticketing System● Multiple issue types with

unique workflows.● Dynamic permissions per

role, type, and status.● User, Help Desk, Admin

Management roles.

Page 17: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #5: Leveraging Bundles

Reusing content definitions through bundles.Session

Title

Location

Timeslot

Description

Image

Track

KeynoteTitle

Location

Timeslot

Description

Image

Banner Image

WorkshopTitle

Location

Timeslot

Description

Image

Track

Registration

SocialTitle

Location

Timeslot

Description

Image

Registration

BOFTitle

Location

Timeslot

Description

Page 18: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #6: Performance Tuning

When performance is an high valued goal.

Page 19: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #6: Performance Tuning

When performance is an high valued goal.Denormalizing can:● Enhance query

performance.● Make a database more

convenient to manage● Facilitate and accelerate

reporting.

Page 20: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Reason #7: Unique Storage

Using non-standard storage for modeled data.

Example: https://www.drupal.org/project/external_entities

Page 21: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Are you Excited? Feel Empowered? Ready to create Entities?

Page 22: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration
Page 23: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

1. Steeper learning curve compared to other Drupal APIs.

2. Less likely contrib modules will work with custom entities.

3. Custom entities may not inherit future Drupal features.

4. Responsible for maintaining custom code - plenty of potential for technical debt.

Reasons not to build a custom entity.

Page 24: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Building with ECK ModuleDemo

Page 25: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Generating with Drupal ConsoleDemo

Page 26: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration

Thank You!

[email protected] @nJim

Page 27: Building Custom Entities Outgrowing Content Types …...Drupal 7 Intentionally an abstract term, entities are objects that are used for persistent storage of content and configuration