With the release of Drupal 11.1, there’s a cool new feature for developers: Hooks can now be implemented as class methods using PHP attributes instead of functions. This change is a major step forward in modernizing Drupal’s codebase. While procedural function-based hooks are still supported (and will be for some time), developers writing new code should strongly consider using the object-oriented (OOP) approach introduced in Drupal 11.1.
One of our core commitments at Drupalize.Me is ensuring that our tutorials remain accurate and relevant as Drupal evolves. So we’re working on updating all of our tutorials to take into account the new OOP approach to adding hooks in a module. We’re also aware that procedural hooks have been around for 24 years, and aren’t going to disappear overnight. You’ll see them in example code and existing documentation for a long time to come. So for now we’ll be including both approaches in our content whenever doing so makes sense.
You should plan on learning both approaches, and then using the one that makes the most sense given your specific case.
Continue reading to learn a bit about the evolution of hooks in Drupal core and how to implement hooks as classes in Drupal 11 in this latest Drupalize.Me blog post by Joe Shindelar.
Routing
TopicDrupal's Routing API maps the URL of an incoming request to the code responsible for generating the content that is rendered in response.
Services
TopicServices are objects that encapsulate the code for performing specific tasks in a reusable and decoupled way.
Plugins (Plugin API)
TopicPlugins are one of the ways that module developers can write code that extends Drupal. The Drupal Plugin API allows a module to provide functionality in an extensible, object-oriented way.
Dependency Injection
TopicDependency injection is a design pattern commonly used in object-oriented software architectures in order to support Inversion of Control.
At Drupalize.Me, we've been talking with Dries and folks at the Drupal Association about how we can contribute high quality documentation for Drupal CMS. The plan for Drupal CMS documentation is emerging. We believe Drupal CMS documentation should be a highly polished and organized user guide for end-users of Drupal CMS. And that it should be funded. Why?
This week, we've added 7 new videos to existing tutorials in our Module Developer Guide. The Module Developer Guide was created for developers familiar with PHP but new to Drupal module development.
We have been working on recording, editing, and publishing videos for the step-by-step "task" tutorials in our Module Developer Guide. As many of these tutorials are code heavy, you have the advantage of a video walk-through as well as code examples to copy and paste in the written version of the tutorial. Read more to see which tutorials in the guide now have videos embedded.
When Drupal CMS launched, we built a guide to help users get started—but now we’re facing a big question: how does it relate to the existing Drupal User Guide? Should we keep them separate or merge them into a single, streamlined resource? In this post, Joe breaks down the challenges, and explores what’s next.
Content Types
TopicA content type is a subtype of the [content entity](link to Entity topic). When a content creator goes to add new content to the site, they are presented with a list of content types to choose from to get the appropriate form to fill out.
Drupal's content moderation and workflow tools allow you to configure and support a flexible multistep publication process.
An overview of some of our favorite Drupal documentation resources.
Fields and the Field API
TopicFields are the building blocks of Drupal's powerful content modeling system. The Field API allows for the development of custom field types to suit almost any data display and collection needs.
Many sites require the ability to upload, manage, and display various assets like files, images, videos, and audio.
Multilingual Sites
TopicA multilingual site has more than 1 language that users interact with, either through the content, the user interface, or both.
Search engine optimization (SEO) is the process of optimizing your online content, so that your content will rank higher in organic (non-paid) search engine results.
Views Module in Drupal
TopicLearn to use data from your Drupal site to create customized lists in various forms, such as bulleted lists, grids, calendars, or sliders.
Debug Drupal Code
TopicDebugging is the practice of troubleshooting an application through the use of tools and processes in order to find and fix bugs, or better understand the underlying code.
Drupal manages information and access for all visitors to your site, called users, through a system of roles and permissions.