Book Image

Drupal 8 Module Development

By : Daniel Sipos
Book Image

Drupal 8 Module Development

By: Daniel Sipos

Overview of this book

Drupal is an open source web-based content management system (CMS) that can be used for building anything from simple websites to complex applications. It enables individuals and organizations to build platforms that engage users and deliver the right content at the right time. Drupal 8 is an exciting new development in the Drupal community. However, the differences from the previous version are substantial and this can put quite some pressure on Drupal 7 developers that need to catch up. This book aims to help such developers in getting up to speed with Drupal 8 module development. The book first introduces you to the Drupal 8 architecture and its subsystems before diving into creating your first module with basic functionality. Building upon that, you will cover many core APIs and functionalities available to module developers. You will work with the Drupal logging and mailing systems, learn how to output data using the theme layer and work with menus and links programmatically. Then, you will learn how to work with different kinds of data storages, create custom entities, field types and leverage the Database API for lower level database queries. Moreover, you will learn about the Drupal 8 access system and caching layer as well as the APIs used for data processing (queues and batches). You will further see how to introduce javascript into your module, work with the various file systems and ensure the code you write works on multilingual sites. Finally, you will learn how to programmatically work with Views, write automated tests for your functionality and also write secure code in general. By the end of the book, you will have learned how to develop your own custom module from scratch that can help solve a small problem or even provide complex functionality. And who knows, maybe you’ll even contribute it back to the Drupal community.
Table of Contents (19 chapters)

What this book covers

Chapter 1, Developing for Drupal 8, provides an introduction to module development in Drupal 8. In doing so, it introduces the reader to the various subsystems and outlines the requirements for running a Drupal 8 application.

Chapter 2, Creating Your First Module, gets the ball rolling by creating the first Drupal 8 module of the book. Its main focus is to explore the most common things module developers need to know from the get-go.

Chapter 3, Logging and Mailing, is about the tools available for doing something every web-based application does and/or should be doing, that is, sending emails and logging events.

Chapter 4, Theming, presents the theme system from a module developer's perspective in Drupal 8.

Chapter 5, Menus and Menu Links, explores the world of menus in Drupal 8 and shows how to programmatically create and work with menu links.

Chapter 6, Data Modeling and Storage, looks at the various types of storage available in Drupal 8, from the state system to configuration and entities.

Chapter 7, Your Own Custom Entity and Plugin Types, takes a hands-on approach creating a custom configuration and content entity type, as well as custom plugin type to wire up a practical functional example.

Chapter 8, The Database API, presents the database abstraction layer and how we can work directly with data stored in custom tables.

Chapter 9, Custom Fields, exemplifies the creation of the three plugins necessary for creating a custom field that can be used on a Drupal 8 content entity type.

Chapter 10, Access Control, explores the world of access restrictions in Drupal 8, from roles and permissions to route and entity access checks.

Chapter 11, Caching, looks at the various cache mechanisms available for module developers to improve the performance of their functionality.

Chapter 12, JavaScript and the AJAX API, introduces module developers to the specificities of writing JavaScript in Drupal 8, as well as the powerful AJAX system, which can be used to build advanced interactions.

Chapter 13, Internationalization and Languages, deals with the practices Drupal 8 module developers need to observe in order to ensure that the application can be properly translated.

Chapter 14, Batches, Queues, and Cron, explores the various ways module developers can structure their data processing tasks in a reliable way.

Chapter 15, Views, looks at the various ways module developers can programmatically interact with Views and even expose their own data to them.

Chapter 16, Working with Files and Images, explores the various file and image APIs that allow module developers to store, track, and manage files in Drupal 8.

Chapter 17, Automated Testing, explores the various types of automated test module developers can write for their Drupal 8 applications to ensure stable and resilient code.