Drupal is a registered trademark of Dries Buytaert

dx_toolkit

6 sites No security coverage
View on drupal.org

DX Toolkit provides reusable developer primitives—standardized patterns and plugin systems that improve code quality and reduce boilerplate in Drupal custom module development. Now available as a beta release for community testing.

  • EntityGenerator plugin system for programmatically creating companion configuration entities. Solves use cases like:
    • Generating a View Mode for every bundle of a custom entity type.
    • Generating a REST Resource configuration for every Content Type
    • Generating a Feed Type for every Taxonomy Vocabulary.
    • FeedTypeGenerator base plugin provides specialized support for the Feeds ecosystem, handling both Feed Type and Feed entity creation and import.
  • ServiceInstance pattern for self-identifying services with inline instantiation support.
    • ServiceInstanceInterface requires implementing classes to declare their service name, enabling MyService::getService() syntax.
    • ServiceInstanceTrait provides the implementation, allowing IDE autocompletion like MyService::getService()->someMethod() in static contexts.
    • Simplifies testing by making mock container injection straightforward.
  • Plugin enhancements via extended base classes for annotation plugin definitions and plugin manager definition.
    • PluginManager includes additional methods:
      • createInstances: Returns all plugin instances, optionally filtered by base plugin ID.
      • getPluginDerivatives: Returns all definitions for a base plugin ID.
      • createDerivativeInstances: Returns all plugin instances for a base plugin ID
      • optionLabels: Returns id/label arrays for use in FAPI #options properties.
    • PluginManagerPropertyQueryInterface / PluginManagerPropertyQueryTrait pair for returning definitions by property values from plugin manager. Gives plugin managers capability similar to entity storage handler's loadByProperties method.
  • Core utility extensions that add production-tested functionality to Drupal's component layer.
    • Environment utility class extends \Drupal\Component\Utility\Environment with enhanced CLI detection.
    • Color utility class extends Drupal\Component\Utility\Color with hex normalization, luminance calculations, and contrast checking (YIQ, luminance, 50% algorithms).
    • Json utility class extends Drupal\Component\Serialization\Json with control character removal and BOM stripping for malformed JSON handling.
  • General purpose utilities:
    • ArrayUtilities class
      • arrayKeysCombined: Combines keys from two arrays into key/value pairs.
      • arrayMapMerged: Provides one-level flattening of the results returned from the provided array_map callback.
      • arrayFlattenRecursive: Provides recursive flattening of the results returned from the provided array_map callback.
      • arrayKeyColumn: Derivative of array_column() function that maintains parent key associations.
      • arraySortByKeys: Sorts one array by the keys of another.
    • AsArrayTrait provides a simple trait for ensuring a value is always an array.
    • OptionsGenerator that generates key/label arrays from an array of entities or a storage handler.
    • StateBase provides an OO wrapper for the State key/value store.
    • ExtensionBase provides extension-specific metadata.

Demo Module: The included dx_toolkit_demo submodule provides working implementations of all plugin systems and patterns. Enable it to see concrete examples of ServiceInjector plugins with derivers, EntityGenerator implementations, and ServiceInstance pattern usage. Use these as templates for your own projects.

Note: This is a Beta release intended for community testing. The plugin systems and utilities have been used in production environments. Please report any bugs or feature requests to the issue queue.

Activity

Total releases
6
First release
Dec 2025
Latest release
3 weeks ago
Release cadence
9 days
Stability
0% stable

Release Timeline

Releases

Version Type Release date
1.0.0-beta5 Pre-release Feb 6, 2026
1.0.0-beta4 Pre-release Jan 25, 2026
1.0.0-beta3 Pre-release Jan 25, 2026
1.0.0-beta2 Pre-release Jan 24, 2026
1.0.0-beta1 Pre-release Dec 21, 2025
1.0.x-dev Dev Dec 21, 2025