Commit 7ccf2577 authored by Nigel McNie's avatar Nigel McNie
Browse files

Base blocktype methods for exporting blockinstance config.

This feeds into the View export. Blocktypes can export all the
information they need to be imported again.
Signed-off-by: default avatarNigel McNie <>
parent 5946ba96
......@@ -275,6 +275,38 @@ abstract class PluginBlocktype extends Plugin {
return true;
* Given a block instance, returns a hash with enough information so that
* we could reconstruct it if given this information again.
* Import/Export routines can serialise this information appropriately, and
* unserialise it on the way back in, where it is passed to {@link
* import_create_blockinstance()} for creation of a new block instance.
* @param BlockInstance $bi The block instance to export config for
* @return array The configuration required to import the block again later
public static function export_blockinstance_config(BlockInstance $bi) {
// TODO: a default implementation might just turn $bi->get('configdata') into an array
return array();
* Creates a block instance from a given configuration.
* The configuration is whatever was generated by {@link
* export_blockinstance_config()}. This method doesn't have to worry about
* setting the block title, or the position in the View.
* @param array $config The config to use to create the blockinstance
* @return BlockInstance The new block instance
public static function import_create_blockinstance(array $config) {
// TODO: a default implementation might just create a new blockinstance
// with the config shunted into configdata - but with artefactids
// replaced with new ones
abstract class SystemBlockType extends PluginBlockType {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment