rearchitecting for drupal 8...prolog

69
Rearchitecting for Drupal 8 By frob

Upload: others

Post on 19-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rearchitecting for Drupal 8...Prolog

Rearchitecting for Drupal 8

By frob

Page 2: Rearchitecting for Drupal 8...Prolog

In case you are wondering

Page 3: Rearchitecting for Drupal 8...Prolog

Prolog <-- You are here in the sessionWhy look at Drupal 8

Custom LMS Drupal 7 architectureFeatures

Content strategy

Modules used

Custom development

Considerations Building with Drupal 8Architectural differences

UI Changes

Module availability

Specifically What needs to change

Page 4: Rearchitecting for Drupal 8...Prolog

Hello My Name Is Frank

I am a Father, and Technology Enthusiast.

Online my name is frob (IRC, d.o, github)

On Twitter I am @frobdfasMy Blog is

I work for Clarity Innovations Inc.

www.frobiovox.com

Page 5: Rearchitecting for Drupal 8...Prolog
Page 6: Rearchitecting for Drupal 8...Prolog
Page 7: Rearchitecting for Drupal 8...Prolog

Why do this?

Page 8: Rearchitecting for Drupal 8...Prolog

I create with Drupal 7.

I want to create with Drupal 8.

I want to know the differences betweencreating with Drupal 7 vs 8.

I would like to know how I can leverage thenew features of Drupal 8 in complicatedinformation systems.

Page 9: Rearchitecting for Drupal 8...Prolog

Lets go from:

Page 10: Rearchitecting for Drupal 8...Prolog

To:

Page 11: Rearchitecting for Drupal 8...Prolog

Custom LMS Architecture

Learning Management SystemAn LMS is software that allows for the organization and delivery of courses or

training programs.

Page 12: Rearchitecting for Drupal 8...Prolog

Traditional LMS

Curriculum or Lesson planUnit or ModuleLesson/Project/Assessment/Mini-lessons

Page 13: Rearchitecting for Drupal 8...Prolog

Our custom LMS is structured

Module -> MenuSegments -> Nodes or Content TypeComponents -> Paragraphs Items

Page 14: Rearchitecting for Drupal 8...Prolog
Page 15: Rearchitecting for Drupal 8...Prolog

Basic Drupal Content Architecture

Entities

Fields

Variables

Page 16: Rearchitecting for Drupal 8...Prolog

Entities

Entities are things in Drupal; things do not have to be nodes.

Page 17: Rearchitecting for Drupal 8...Prolog

Bundles and Fields

A bundle is a collection of fields instanceson an Entity

A field instance is a place for complex datain a Entity Bundle

A property is simple storage for Entity leveldata

Page 18: Rearchitecting for Drupal 8...Prolog

Properties

Properties are linked to an Entity, such as Node. Fields are linked to the Bundle, suchas Content Type.

Properties are stored on the entity's table and fields are stored in their own table.

Page 19: Rearchitecting for Drupal 8...Prolog

Variables

Variables are what Drupal 7 provides for configuration --when it isn't a custom table.

Page 20: Rearchitecting for Drupal 8...Prolog

LMS Features

Support Backwards Design philosophy

Page 21: Rearchitecting for Drupal 8...Prolog

Goals of lesson planning

Engage

Explore

Explain

Elaborate

Evaluate

Page 22: Rearchitecting for Drupal 8...Prolog

LMS Lesson Goals

Teaching

Application

Assessment

Page 23: Rearchitecting for Drupal 8...Prolog

Drupal 7 Modules Used

Frank's list of modern site building tools

Page 24: Rearchitecting for Drupal 8...Prolog

Paragraphs allows us to create collections of fields. Each collection type is its ownbundle and can have its own fields.

Paragraphs

Page 25: Rearchitecting for Drupal 8...Prolog

Named eForm in Drupal 8. Allows the use of the field api to create webform and havethe submissions be entities.

Entity Form

Page 26: Rearchitecting for Drupal 8...Prolog

Solves the problem of putting views into entities as pseudo-fields.

Eva

Page 27: Rearchitecting for Drupal 8...Prolog

This module allow users to flag things. Largest use is probably the "Flag this asinappropriate" functionality.

Flag

Page 28: Rearchitecting for Drupal 8...Prolog

Coffee works like Unity for Ubuntu or Spotlight search for Mac, or the Start Menu inWindows. Just start typing and a list of options will be presented. Pick the option and

it will take you there.

Coffee

Page 29: Rearchitecting for Drupal 8...Prolog

Check more than one box with a click and drag mechanic.

Speedboxes

Page 30: Rearchitecting for Drupal 8...Prolog

A word on Blocks

Bean is an acronym that stands for:

Block Entities Aren't Nodes.

Bean

Page 31: Rearchitecting for Drupal 8...Prolog
Page 32: Rearchitecting for Drupal 8...Prolog
Page 33: Rearchitecting for Drupal 8...Prolog

LMS Content Strategy

Arguably, the most important part of a site.

Page 34: Rearchitecting for Drupal 8...Prolog

13 paragraphs types and 1 content type

Three where interactive

Text response

Checkbox list

Drag and Drop

Page 35: Rearchitecting for Drupal 8...Prolog

Text response

Page 36: Rearchitecting for Drupal 8...Prolog

Checkbox list

Page 37: Rearchitecting for Drupal 8...Prolog

Drag and Drop

Page 38: Rearchitecting for Drupal 8...Prolog

The rest are multimedia/content.

Everything can be combined to form larger whole components.

Page 39: Rearchitecting for Drupal 8...Prolog

Linking the EntityForm Submission to the Paragraph item

Entity Machine Name

Paragraph Type text_response

EntityForm Type text_response

Page 40: Rearchitecting for Drupal 8...Prolog

Evaluation

Sharing via Flags on the paragraphs items

Page 41: Rearchitecting for Drupal 8...Prolog

Custom Development

Page 42: Rearchitecting for Drupal 8...Prolog

Pass the build to custom function

if (!empty($build['#bundle'])) { $bundle = $build['#bundle']; if (function_exists("_component_{$bundle}_alter")) { // We need to pass build in an array in order to trick call user func // into passing the build by reference. call_user_func("_component_{$bundle}_alter", array(&$build)); } }

Page 43: Rearchitecting for Drupal 8...Prolog

Text response callback

/** * Implements custom _component_TYPE_alter(). */ function _component_text_response_alter(&$build) { if (isset($build[0]['#entity']) && !empty($build[0]['#entity' module_load_include('inc', 'entityform', 'entityform.admin' $entity_form_name = 'text_submissions'; $component_id = $build[0]['#entity']->item_id; $entity = $build[0]['#entity']; $form = _get_entityform(entityform_empty_load($entity_form_name), $form['field_component_submission']['#attributes']['class' // ... Other Stuff ... $form['field_text_response_submission']['#attributes']['class' $form_rendered = drupal_render($form); $build[0][] = array(

Page 44: Rearchitecting for Drupal 8...Prolog

Considerations Building a LMS with Drupal 8

Architectural differences

UI Changes

Module availability

Specifically What needs to changeArchitectureCustom DevelopmentContent strategy

Page 45: Rearchitecting for Drupal 8...Prolog

General Drupal 8 Considerations

Setup the devel module

It is now cache rebuilding

Modules cannot be disabled

Enable Developer Mode

Beware of online sources

Page 46: Rearchitecting for Drupal 8...Prolog

Architectural Differences

Configuration Entities

Semantic Versioning

Blocks

View Modes

New field types (entity reference, link,telephone)

Page 47: Rearchitecting for Drupal 8...Prolog

Things to google (many have been backported to Drupal 7)

Composer support

Toolbar update (Navbar in Drupal 7)

Responsive Image Styles (Picture Modulein Drupal 7)

File Entities

RESTful api

Experimental Core Modules

Content Moderation

etc...

Page 48: Rearchitecting for Drupal 8...Prolog

UI Changes

Good News! Not much has changed significantly in the UI. I guess that could be badnew too.

Page 49: Rearchitecting for Drupal 8...Prolog

Operations

New Drop down thingy for selecting what we are doing to a thing.

Page 50: Rearchitecting for Drupal 8...Prolog

Form Display Settings

Multiple entity form settings on the Manage form display page, this includes fieldwidget settings.

Page 51: Rearchitecting for Drupal 8...Prolog

Good news about learning curves

Page 52: Rearchitecting for Drupal 8...Prolog

Module Availability

Page 53: Rearchitecting for Drupal 8...Prolog

Big problemEntityForm is not supported on Drupal 8Find an alternativeCustom Entity

Comment module

Contact module extras

Relation module

Fund the development of a stable release

Page 54: Rearchitecting for Drupal 8...Prolog

Second problemParagraphs doesn't want me to referenceparagraphs

It is possible, but requires use of theEXPERIMENTAL field widget.

In this case the problem wasn't themodule but my own unfamiliarity and overconfidence. The answer was staring me inthe face.

Page 55: Rearchitecting for Drupal 8...Prolog
Page 56: Rearchitecting for Drupal 8...Prolog

Specifically What needs to change

Not Much

Page 57: Rearchitecting for Drupal 8...Prolog

Architecture & Content Strategy

Mostly the same

Same Features

Same Modules

Same Architecture

Same Strategy

Page 58: Rearchitecting for Drupal 8...Prolog

Custom Development

Biggest Changes

Page 59: Rearchitecting for Drupal 8...Prolog

Custom Development

This is where the largest changes where made.

Page 60: Rearchitecting for Drupal 8...Prolog

Not Much

We still use hook_entity_view_alter

We still use hook_form_alter

Page 61: Rearchitecting for Drupal 8...Prolog
Page 62: Rearchitecting for Drupal 8...Prolog

Okay, really lots

But all good!

Page 63: Rearchitecting for Drupal 8...Prolog

Drupal 8 version:

// This creates a new eform submission. $eform_submission = \Drupal::entityTypeManager() ->getStorage('eform_submission') ->create(['type' => 'multiple_choice_question']); // This loads an existing eform submission. $submitted_eform = \Drupal::entityTypeManager() ->getStorage('eform_submission')->load(2); // Either way we build the form with a call to the entity.form_builder service.$form = \Drupal::service('entity.form_builder') ->getForm($submitted_eform); // Then we append it to the render array. $build[] = $form;

Page 64: Rearchitecting for Drupal 8...Prolog

No more Drupal 7 non-existent entity api

Drupal 8 has intelligent use of OOP thatmakes site building easier

Over 100 lines of code is reduced to under10

Page 65: Rearchitecting for Drupal 8...Prolog
Page 66: Rearchitecting for Drupal 8...Prolog

Why look at Drupal 8

Custom LMS Drupal 7 architecture

Considerations Building a with Drupal 8Architectural differences

UI Changes

Module availability

Specifically What needs to change

Conclusion <-- Achievement unlocked

Page 67: Rearchitecting for Drupal 8...Prolog
Page 68: Rearchitecting for Drupal 8...Prolog

When are sprints?

April 24-27: Sprint Lounge at Baltimore Convention Center

April 28: Sprint Day - General Sprints, Mentored Core Sprint, First-Time SprinterWorkshop at Baltimore Convention Center

We also provide a 24-hour Sprinter Lounge that opens on April 24th at 7:00pm andwill close on Thursday, April 27th at midnight. The Sprinter Lounge will be located at

the Hilton Baltimore (401 West Pratt Street) in room Peale A-C.

Based on community feedback and input from the Sprint Leads, we understand theneed for 'shorter sprints with greater support', and as a result will not be hosting

Extended Weekend Sprints at this DrupalCon.

Page 69: Rearchitecting for Drupal 8...Prolog

Don't forget to give me feedback

node/17242