![]() |
CMS
Version 3.9
|
SerializationManager handles import/export of DataItems via an XML file. More...
Public Member Functions | |
__construct () | |
Creates a SerializationManager, building the serialization map from the registered components via the RegisterSerializationHandler event. More... | |
registerHandler ($component, $title, $handler) | |
Registers a serialization handler for a component. More... | |
export ($components) | |
Exports data for the specified components. More... | |
exportAll () | |
Export data for all registered components. More... | |
import ($xml, $components) | |
Imports data from the specified XML document for the specified components. More... | |
importBackground () | |
importAll ($xml) | |
Import data for all registered components. More... | |
Static Public Member Functions | |
static | unserialize ($class, $doc, $tx, $save=true) |
Instantiates DataItems from the supplied XML document and stores them in the database. More... | |
static | store ($class, $doc, $tx) |
static | serialize ($class, $constraint="") |
Serializes the specified DataItems to XML. More... | |
Static Public Attributes | |
static | $map |
SerializationManager handles import/export of DataItems via an XML file.
This allows data to be transferred between Fakoli instances that provide the same data model (for instance, between development and production versions of the same application).
To implement serialization for your Fakoli component, add a line to your manifest specifying that you can recieve the RegisterSerializationHandler event. Your callback for this event you then use the SerializationManager::registerHandler method to register the serialization handler in charge of serializing your data model. Two standard serializers are provided - SimpleSerializationHandler will serialize a single DataItem class. CompoundSerializationHandler serializes a set of classes grouped together in the XML format under a common tag. You can provide custom serialization handlers for more complex needs (should they arise) by implementing the SerializationHandler interface and providing your own implementation.
Definition at line 47 of file serialization_manager.inc.
SerializationManager::__construct | ( | ) |
Creates a SerializationManager, building the serialization map from the registered components via the RegisterSerializationHandler event.
Definition at line 55 of file serialization_manager.inc.
SerializationManager::export | ( | $components | ) |
Exports data for the specified components.
string | $components | a comma-separated list of the components for which data is to be exported |
Definition at line 81 of file serialization_manager.inc.
SerializationManager::exportAll | ( | ) |
Export data for all registered components.
Definition at line 107 of file serialization_manager.inc.
SerializationManager::import | ( | $xml, | |
$components | |||
) |
Imports data from the specified XML document for the specified components.
Any other data in the XML document is ignored.
string | $xml | the file path of the XML document containing the serialized data |
string | $components | a comma-separated list of the components for which data is to be exported |
FakoliException | |
Exception |
Definition at line 121 of file serialization_manager.inc.
SerializationManager::importAll | ( | $xml | ) |
Import data for all registered components.
string | $xml | the file path of the XML document containing the serialized data |
Definition at line 177 of file serialization_manager.inc.
SerializationManager::importBackground | ( | ) |
Definition at line 127 of file serialization_manager.inc.
SerializationManager::registerHandler | ( | $component, | |
$title, | |||
$handler | |||
) |
Registers a serialization handler for a component.
string | $component | the component for which the handler is being registered (i.e. "blog") |
string | $title | the display title describing the data that is serialized for this component (i.e. "Blogs and Articles") |
SerializationHandler | $handler | the serialization handler object providing the implementation |
Definition at line 71 of file serialization_manager.inc.
|
static |
Serializes the specified DataItems to XML.
This utility method is provided to simplify the implementation of SerializationHandlers.
string | $class | the target DataItem class |
string | $constraint | optional database constraint for the objects to be serialized |
Definition at line 309 of file serialization_manager.inc.
|
static |
|
static |
Instantiates DataItems from the supplied XML document and stores them in the database.
This utility method is provided to simplify the implementation of SerializationHandlers.
string | $class | the target DataItem class |
DOMDocument | $doc | the source XML document |
DataTransaction | $tx | The database transaction to join when creating imported objects |
bool | $save | true to save to the database, false to just return the reconstituted objects |
Definition at line 192 of file serialization_manager.inc.
|
static |
Definition at line 49 of file serialization_manager.inc.