While developing the mutlisite support we realized once more how helpful it would be if one were able to inherit configurations instead of copying them. After some thoughts I came to the conclution that it might be rather simple to support this by implementing an other content wrapper which merges the content under the hood.
The wrapper checks the existence of a nodedata named 'extends' which can define a absolut or relative path to an other node.
You can see a demonstration in the following short video:
First I had to re-factor/improve the content API to make that wrapper extendable in a easier way. Then I have just created some tests and added the implementation. Once this was done I just searched the two places where I have to wrap the passed configuration before processing:
- content2bean (used to build filters, modules, templates and various other components, ..)
- dialog manager (responsible to transform a configuration into a dialog)
The merge is then performed as follows (taken from the javadoc):
- node datas are merged and values are overwritten
- sub content nodes are merged, the original order is guaranteed, new nodes are added at the end of the list
- the node the current node inherits from can again extend a node
- nodes laying deeper in the hierarchy can extend an other node