Patterns is a rather complex module, therefore it could take longer than usual to developers and contributors to feel confident with its codebase. This page aims at introducing the Patterns module from a developer perspective. If you want to have a deeper overview of the module after finishing reading this section, please visit the tour of the code section.
This page is still incomplete, if you are a Patterns developer feel free to contribute to it.
The directory structure
Patterns is divided in the following subfolders:
components: contains the components' code for running the patterns. If you want to write a pattern component for your own module, this one is probably the folder to look into to get some good examples.
includes: a large set of helping and core functions used by the Patterns module. The name of the includes are usually self-explicative.
js: contain a set of statis css and js files used by Patterns.
patterns: contains a number of examples of patterns files. You should not place your own patterns here, but rather create your own patterns directory somewhere in your file system.
tests: a fairly comprehensive battery of simple tests to check that Patterns is functioning as expected.
patterns_*: directories starting with this prefix contain a submodule. Please read the .info file for a description.
Important Patterns API
If you want to integrate your module with Patterns you will find useful the following methods:
patterns_io_save_pattern($content = NULL, $name = NULL, $format = 'yaml', $dir = NULL): save a valid pattern into the specified pattern directory and into the database. If the pattern code is invalid return FALSE.
patterns_db_save_pattern($pattern, $path, $name): save a pattern into the database. No validation is performed, therefore it should be used carefully. If a pattern with the same name is found, it updates it.
Important Patterns hooks
Please read here.
- Since patterns codebase grew large, all functions are named after the include they are part of. e.g.
patterns_io_save_patterncan be found inside