Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Drupal 9 Module Development

You're reading from   Drupal 9 Module Development Get up and running with building powerful Drupal modules and applications

Arrow left icon
Product type Paperback
Published in Aug 2020
Publisher Packt
ISBN-13 9781800204621
Length 626 pages
Edition 3rd Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Daniel Sipos Daniel Sipos
Author Profile Icon Daniel Sipos
Daniel Sipos
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Chapter 1: Developing for Drupal 9 2. Chapter 2: Creating Your First Module FREE CHAPTER 3. Chapter 3: Logging and Mailing 4. Chapter 4: Theming 5. Chapter 5: Menus and Menu Links 6. Chapter 6: Data Modeling and Storage 7. Chapter 7: Your Own Custom Entity and Plugin Types 8. Chapter 8: The Database API 9. Chapter 9: Custom Fields 10. Chapter 10: Access Control 11. Chapter 11: Caching 12. Chapter 12: JavaScript and the Ajax API 13. Chapter 13: Internationalization and Languages 14. Chapter 14: Batches, Queues, and Cron 15. Chapter 15: Views 16. Chapter 16: Working with Files and Images 17. Chapter 17: Automated Testing 18. Chapter 18: Drupal Security 19. Other Books You May Enjoy

Summary

In this chapter, we covered a great deal of info about the things you need to know when developing Drupal 9 modules. The first thing we did was create our very own module skeleton that can be installed on a Drupal site. Then, we saw how to create a new page at a specific path (route) and show some basic data on that page. Nothing too complex, but enough to illustrate one of the most common tasks you will do as a module developer. We then took that to a new level and abstracted the logic for that data calculation into a service. Not only that, but we also saw how we can use that service and, more importantly, how we should use it. Next, we saw how we can work with the Form API to allow administrators to add some configuration to the site. Also, since we talked about forms, we saw how we can alter existing ones defined by other modules—a useful technique for any module developer.

Next, we created our first custom block, which allowed us to reuse our service and be more flexible with where we show our data.

Then, we looked at how to create URLs and links programmatically. In the functionality we built in this module, we don't need any links, yet. However, it is common practice to work with them, so we had to learn early how to generate links and work with URLs properly in Drupal.

In the last section, we explored the Symfony Event Dispatcher component, something that allows us to dispatch and subscribe to events. We saw some examples of how we can subscribe to one of the main Kernel events in order to redirect the page, but we also saw how to dispatch our own event. The latter was meant to allow subscribers to make changes to our data.

Most of the topics we covered in this chapter were meant to give you an initial boost and the tools to start developing modules in Drupal 9. They represent the absolute most common things—I believe—that any new Drupal developer encounters and has to do.

In the next chapter, we will look at two important aspects most applications will need to use. One is logging—the better your site logs its errors and important actions, the easier it will be to debug and trace back issues. Another is mailing. Websites usually need to send out emails to users in one way or another, so it's important that we see how that works in Drupal 9.

You have been reading a chapter from
Drupal 9 Module Development - Third Edition
Published in: Aug 2020
Publisher: Packt
ISBN-13: 9781800204621
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime