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).

content_fixtures

70 sites Security covered
View on drupal.org

Introduction

Do you want to build a running website straight from your repository, but you realized that you have to get some dummy content from somewhere? Search no more. This module will give you an API to program your own content generators, that you will be able to run with one command, and fill your website with content required either for development or presentation.

This module is different from data_fixtures in that it aims to mimic as much as it's reasonably possible DoctrineFixturesBundle.

It was made with a workflow of programmatically building your website from scratch in mind, and tries to avoid any ambiguous states, that's why it deletes all content before loading any fixtures (don't worry, it will warn you :) ).

Great match with Docker, if you are looking for ultimate automation.

How to

This module has API very similar to DoctrineFixturesBundle, with some Drupal-specific differences/simplifications.

Basics

Minimally, your fixture class has to implement FixtureInterface, and be registered as a service tagged with a content_fixture tag.

Sharing objects between fixtures.

The easiest way of achieving this is to extend AbstractFixture class, that will provide you with some additional sugar - this abstract class implements SharedFixtureInterface that will give you a way of sharing created objects between fixtures.

Order of execution of fixtures

For this to work, you have to be able to decide on the order of execution of fixtures, and you can do this in two ways:

1. By implementing OrderedFixtureInterface - this will allow you to assign a value to each fixture, that will be used for ordering.
2. By implementing DependentFixtureInterface, that will allow you to declare dependencies between fixtures, and order of execution will be calculated by using this information.

Groups

You can also implement FixtureGroupInterface in your fixture, to assign it to some custom groups. It will allow you to run fixtures by groups they belong to. This way you can have different set of fixtures for presentation, different for development etc.

Execution

You need drush to run your fixtures. Module provides you with three commands:

  • content-fixtures:list
  • content-fixtures:load
  • content-fixtures:purge

See: drush help content-fixtures:list, drush help content-fixtures:load, and drush help content-fixtures:purge.

Other

If you like code quality of this module but you would rather like to have exportable hand-made content, then you may consider content_snapshot module.

Happy coding!

Activity

Total releases
1
First release
Jan 2025
Latest release
1 year ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
3.2.0 Stable Jan 17, 2025