Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

crema

No security coverage
View on drupal.org

…And the idea also is pretty insane and silly anyway…

A PoC module which aim to "replace" PHP classes you define in your module's info.yml file.

Usage

  1. Add a new key class_replacements to the .info.yml of the module which contains the replacement modules:
    name: Migration Manager Replacement
    type: module
    class_replacements:
      # Key: the qualified name of the class which should be replaced.
      # Value: location of the replacement file, relative to the actual module's root.
      Drupal\migrate\Plugin\MigrationPluginManager: src/migrate/MigrationPluginManager.php
      Drupal\migrate_drupal\MigrationPluginManager: src/migrate_d/MigrationPluginManager.php
    
  2. Make sure that the module depends on crema; or have a good reason not doing so 🙃
  3. Create the replacement file at the declared location:
    • Its namespace must be the namespace of the original file with the leading Drupal replaced by Crema.
    • The class name must be the same as the replaced class name.
    • If you want to extend the original class (I'm pretty sure you want to), then you can do it by adding the proper (aliased) use declaration of the original class.
    # File content of <module_root>/src/migrate/MigrationPluginManager.php
    <?php
    
    namespace Crema\migrate\Plugin;
    
    use Drupal\migrate\Plugin\MigrationPluginManager as Original;
    
    /**
     * Replaces the default migration plugin manager.
     */
    class MigrationPluginManager extends Original {
    
      protected $defaults = [
        'class' => '\Drupal\my_module\Plugin\BetterMigration',
      ];
    
      public function foo(): string {
        return 'foo';
      }
    
    }
    

Limitations

  1. You cannot replace the same PHP class (or trait or interface) more than once.
  2. Due to the way how Crema works, you cannot use debugger breakpoint neither in the replacement nor in the replaced php file.
  3. The module only can replace files with Drupal\* namespace, and not all of them, but most of them. For example you cannot replace Drupal kernels, database driver classes etc.
  4. Crema uses PHP's temporary stream to store the replaced and the replacement files before it loads them. Because of this, (for now) the files must me smaller than 2MB: https://www.php.net/manual/en/wrappers.php.php#wrappers.php.memory

Activity

Total releases
1
First release
Dec 2025
Latest release
4 months ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.0.0-alpha4 Pre-release Dec 4, 2025