How does the Patterns module work?
Patterns is designed to:
- be modular
- be scalable
- be maintainable
- re-use as much existing Drupal code as possible
- be as user-friendly as possible
Patterns works by emulating user clicks. What it does is simply send pre-formatted data to the specified Drupal form. The form gets executed and the database is immediately updated.
For performance reasons, the Drupal Batch system is used to execute many forms in sequence.
Patterns is modular
The code can easily be divided into components that roughly correspond to existing Drupal modules. Each component is an interface between the pattern file and a number of forms for which it is responsible. For example, the Taxonomy component takes care of translating an input file containing vocabularies and terms data into what is required by the system.
Patterns is scalable
Patterns files can be a small as necessary. They can fine-tune specific features, or configure the whole web site. Sections can be created to group coherent actions together. Patterns also supports sub-pattern and multi-pattern functionality (under development in v. 7.x).
Patterns is maintainable
Patterns files do not need to be updated when a new version of Drupal comes out. Updating the components can incorporate all the necessary changes to the form structure.
Patterns re-use as much native Drupal code as possible
That comes for free by using the Form API. In fact, the very same forms clicked by users are submitted by the Patterns module. This way, all the validation routines are performed, and new data can safely be inserted into the database.
Patterns is flexible
Sometimes re-using existing form structures can be cumbersome or impracticable. For this reason, custom functions can be specified to act as action handlers.
Patterns files are human-readable
Patterns syntax is supposed to be intuitive, or at least human-readable, thanks to the YAML format support. Continuous improvements are added to make it even easier to understand. There is also XML and PHP support, currently under development for 7.x.