Extending and altering Drupal

Same name in other branches
  1. 8.9.x core/core.api.php \extending
  2. 10 core/core.api.php \extending
  3. 11.x core/core.api.php \extending

Overview of extensions and alteration methods for Drupal.

Types of extensions

Drupal's core behavior can be extended and altered via these three basic types of extensions:

Alteration methods for modules

Here is a list of the ways that modules can alter or extend Drupal's core behavior, or the behavior of other modules:

  • Hooks: Specially-named functions that a module defines, which are discovered and called at specific times, usually to alter behavior or data. See the Hooks topic for more information.
  • Plugins: Classes that a module defines, which are discovered and instantiated at specific times to add functionality. See the Plugin API topic for more information.
  • Entities: Special plugins that define entity types for storing new types of content or configuration in Drupal. See the Entity API topic for more information.
  • Services: Classes that perform basic operations within Drupal, such as accessing the database and sending email. See the Dependency Injection Container and Services topic for more information.
  • Routing: Providing or altering "routes", which are URLs that Drupal responds to, or altering routing behavior with event listener classes. See the Routing and menu topic for more information.
  • Events: Modules can register as event subscribers; when an event is dispatched, a method is called on each registered subscriber, allowing each one to react. See the Events topic for more information.

*.info.yml files

Extensions must each be located in a directory whose name matches the short name (or machine name) of the extension, and this directory must contain a file named machine_name.info.yml (where machine_name is the machine name of the extension). See \Drupal\Core\Extension\InfoParserInterface::parse() for documentation of the format of .info.yml files.

File

core/core.api.php, line 1243


Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.