Book Image

Drupal 8 Module Development - Second Edition

By : Daniel Sipos
Book Image

Drupal 8 Module Development - Second Edition

By: Daniel Sipos

Overview of this book

Drupal 8 comes with a release cycle that allows for new functionality to be added at a much faster pace. However, this also means code deprecations and changing architecture that you need to stay on top of. This book updates the first edition and includes the new functionality introduced in versions up to, and including 8.7. The book will first introduce you to the Drupal 8 architecture and its subsystems before diving into creating your first module with basic functionality. 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. 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, you will have learned how to develop your own custom module that can provide complex business solutions. And who knows, maybe you’ll even contribute it back to the Drupal community. Foreword by Dries Buytaert, founder of Drupal.
Table of Contents (20 chapters)

JavaScript in Drupal

Drupal 8 relies on a number of JavaScript libraries and plugins to perform some of its frontend tasks. For example, the use of Backbone.js is another example of advancement from previous versions of Drupal when it comes to adopting established libraries rather than reinventing new ones. Of course, as we've already seen, the ubiquitous jQuery library continues to be used in Drupal 8 as well. But of course, there are others.

Another thing I have already mentioned, but which is helpful to bring up again, is the fact that Drupal no longer loads things such as jQuery or its Ajax framework on all pages needlessly. For example, many pages serving anonymous users that do not require jQuery won't even load it. This can greatly improve performance. But it also means that when we define our libraries to include our own JavaScript files, we must always declare...