Case Study - Migrating the Optimizely Module from Drupal 7 to Drupal 8

Since mid-2014 I've been converting the Optimizely module from its Drupal 7 incarnation into a version for Drupal 8, tracking its releases as they have been made. As I've progressed, I have been blogging regularly at:   http://optimizely-to-drupal-8.blogspot.com/

Using those posts for material, this session is for Drupal 7 module developers to introduce them to a few aspects of Drupal 8 modules.

An outline is provided below. Actual code and other examples from the Optimizely module will be used.

 

Case Study - Migrating the Optimizely Module from Drupal 7 to Drupal 8

The Optimizely module

  What it does

  Forms

  Database

  Path management

Configuration in .yml files

  optimizely.info.yml

  optimizely.permissions.yml

  optimizely.routing.yml

  optimizely.links.task.yml

File and code structure

  Directory structure, PSR-4 autoloading, namespaces

  Classes and methods instead of global functions

    Example: implementing a submission form

    Example: implementing a delete confirmation

Twig templates for theming

  Simpler, more intuitive syntax

Other changes

  Placement of functions into classes

  Renaming of functions

  Changes to parameters, e.g. use of routes instead of paths

Quick re-install during development

  Drop all tables in the database

  Remove everything in  sites/default except default.settings.php and default.services.yml

Random Tips

  Requires PHP 5.4

  Learn basic concepts of OOP

  Search through the core code itself for examples

  Autoloading does not work in hook_install

  Problems in hook_install are a big PITA

Sources:

  Optimizely Module: Notes on Converting to Drupal 8

  http://optimizely-to-drupal-8.blogspot.com/

  Upgrading Your Modules, Angela Byron

  http://drupalwatchdog.com/volume-4/issue-1/upgrading-your-modules

  Change records for Drupal core

  https://www.drupal.org/list-changes

  Migrating Content into Drupal 8

  http://www.metaltoad.com/blog/migrating-content-drupal-8

 

Experience level: 
Intermediate
Speaker(s): 
Earl Fong

Session Tracks (DrupalCamp NJ 2015)