What will you learn
- Overview of hooks, their purpose, and how they work
- How to implement a hook of any type
- What plugins are, their purpose, related terminology, and how they work
- Recipe for implementing any plugin type
- Discovering and using existing services
- Subscribing to existing events
- Defining new events and dispatching them from a custom module
- Differences between hooks and events
Overview
In this guide for developers, you'll learn how to alter, extend, and enhance Drupal through hooks, plugins, events, and services.
Hooks in Drupal are predefined points in the code where developers can insert custom functions to modify or extend core behavior without altering core files, making them essential for implementing custom functionality and maintaining upgradability.
Plugins in Drupal are reusable, interchangeable pieces of functionality defined by standardized interfaces, and knowing how to use them is crucial for developers to create modular, extendable components that enhance site functionality while promoting code reuse and maintainability.
Services are reusable PHP objects that encapsulate specific functionality or logic, as a module developer you’ll need to know how to discover and use existing services as well as author new ones for your application specific logic.
Events in Drupal are a mechanism for triggering and responding to specific actions within the system, and developers need to know how to use them to implement custom behaviors and integrations in a decoupled and flexible manner.
Drupal developer learning resources
Hooks
This course covers what hooks are, how they enable modules to alter or extend Drupal's core functionality, and the process of implementing, discovering, and defining new hooks.
In this related topic, you'll find both Drupalize.Me and external resources to help you along.
Plugins
This course covers the fundamental concepts of the Plugin API, including plugin types, discovery mechanisms, and how to implement and manage plugins. Learn to define new plugin types, use plugin managers, and understand the role of plugin factories and derivatives.
In this related topic, you'll find both Drupalize.Me and external resources to help you along.
Services
This course covers the fundamental concepts of services and the service container, including how to discover and use existing services, and the best practices for injecting these services into your code.
In these related topics, you'll find both Drupalize.Me and external resources to help you along.
Events
This course covers the fundamental concepts of events, including how to discover existing events, subscribe to them, and dispatch new events.
In this related topic, you'll find both Drupalize.Me and external resources to help you along.