Tuesday, February 2, 2010

Configuration Inheritance (Magnolia 4.3)

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 mechanism supports multiple inheritances as such:
  • the node the current node inherits from can again extend a node
  • nodes laying deeper in the hierarchy can extend an other node


Boris Kraft said...

Please add a link to the full size video - your player doesn't allow to do a full screen, and now the video is too small to see anything useful

Philipp Bärfuss said...

Have just uploaded the video to youtube and embedded that one instead.

Boris Kraft said...

Excellent, it works much better now!