The field formatter module formats field data for viewing by the end user. Field formatters are defined as plugins, so it's recommended to review the Plugin API before writing a new field formatter.
Field Formatter Class
File: /modules/random/src/Plugin/Field/FieldFormatter/RandomDefaultFormatter.php
Overview of Event Systems
Event systems are used in many complex applications as a way to allow extensions to alter the behavior of the system. An event system can be implemented in various ways, but the concepts and components that make up the system are generally the same.
Creating a Views display style plugin may seem like a daunting task, but it's easier than it looks. Here's a step-by-step guide on how to do it, complete with source code.
You can download the ready-made code here: TARDIS (although it's still in dev). And if you need an introduction to Drupal 8 modules, here's a practical guide to creating basic Drupal 8 modules.
Part III of the practical guide to creating basic Drupal 8 modules
From .info to tests, just the basics
Part VI of the practical guide to creating basic Drupal 8 modules
From .info to tests, just the basics
Hooks are one of the ways modules interact with other contributed modules or Drupal core subsystems. Hooks are used for a variety of tasks, including preprocessing variables for template files (hook_preprocess()), modifying information lists (hook_tokens_alter(), hook_views_data_alter()), and manipulating forms (hook_form_alter()), among other things. This page lists all hooks provided by core.
This documentation is for modules. For information about themes, see Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme.
In Drupal 8, stylesheets (CSS) and JavaScript (JS) are loaded using the same system for both modules (code) and themes: the asset library. Asset libraries can include one or more CSS resources, one or more JS resources, and one or more JS settings.
Drupal 8 introduces many new APIs and includes only some of the APIs from Drupal 7/6. This section provides a detailed overview of the APIs available in Drupal 8.
Before diving into the documentation below, you might want to review the fundamentals and prerequisites as well as the Drupal 8.x module development guides, which explain some of the concepts and terminology assumed in the API documentation here.
API Features
Organized by the least frequently used APIs:
Authentication Provider Services
Implement \Drupal\Core\Authentication\AuthenticationProviderInterface and use the service tag 'authentication_provider'.
_auth Option on Routes
The default authentication manager (see below) allows developers to restrict the set of allowed authentication mechanisms to a specified subset by defining _auth in the route options.
Example: _auth: ['basic_auth', 'cookie']