45 private $serializedOIDs = [];
51 if (is_object($data)) {
54 $syntaxOk = (is_array($data) &&
55 (isset($data['oid']) || isset($data['className'])) &&
56 isset($data['attributes']));
58 if ($syntaxOk && isset($data['oid']) && preg_match('/^\{.+\}$/', $data['oid'])) {
68 if (!isset($data['className']) && !isset($data['oid'])) {
73 if (!isset($data['oid'])) {
74 $oid = new ObjectId($data['className']);
85 if (isset($data['attributes'])) {
86 foreach($data['attributes'] as $key => $value) {
96 if ($parent != null) {
97 $parent->addNode($node, $role);
101 foreach ($data as $key => $value) {
102 if (in_array($key, self::NODE_KEYS)) {
106 return ['node' => $node, 'data' => $data];
113 if (!($node instanceof Node)) {
117 $curResult['className'] = $node->getType();
118 $curResult['oid'] = $node->getOID()->__toString();
119 $curResult['lastChange'] = strtotime($node->getValue('modified'));
121 $oidStr = $node->getOID()->__toString();
122 if (in_array($oidStr, $this->serializedOIDs)) {
124 $curResult['isReference'] = true;
128 $curResult['isReference'] = false;
129 $this->serializedOIDs[] = $oidStr;
135 foreach($valueIter as $valueName => $value) {
136 $values[$valueName] = $value;
138 $curResult['attributes'] = $values;
142 $mapper = $node->getMapper();
143 foreach ($mapper->getRelations() as $relation) {
144 $role = $relation->getOtherRole();
145 $relatedNodes = $node->getValue($role);
148 $isMultiValued = $relation->isMultiValued();
149 if ($isMultiValued) {
150 $curResult['attributes'][$role] = [];
151 foreach ($relatedNodes as $relatedNode) {
155 $curResult['attributes'][$role][] = $data;
163 $curResult['attributes'][$role] = $data;
NodeSerializer implementations are used to serialize Nodes into an array representation or deserializ...
NodeValueIterator is used to iterate over all persistent values of a Node (not including relations).
IllegalArgumentException signals an exception in method arguments.
deserializeValue(Node $node, $key, $value)
Deserialize a node value.
ObjectId is the unique identifier of an object.
static parse($oid)
Parse a serialized object id string into an ObjectId instance.
deserializeNode($data, Node $parent=null, $role=null)
getNodeTemplate($oid)
Get a Node instance based on the original values to merge the deserialized values into.
NodeSerializerBase is a base class for NodeSerialize implementations.
Node adds the concept of relations to PersistentObject.
DionysosNodeSerializer is used to serialize Nodes into the Dionysos format and vice versa.