private static function exportObject(Object_Abstract $object, $key = null) { if ($object->getId() !== self::ROOT_ID) { $objectData = array(); $objectClass = get_class($object); $objectData['class'] = $objectClass; if ($objectClass != 'Object_Folder') { foreach ($object->getClass()->getFieldDefinitions() as $field) { $property = ucfirst($field->getName()); $fieldtype = $field->getFieldtype(); $value = $object->{'get' . $property}(); $objectData[$property] = PimPon_Object_Encoder::encode($value, $fieldtype); } } foreach (self::$includeMethods as $method) { if (method_exists($object, $method) === false) { continue; } $property = ucfirst(substr($method, 3)); $value = $object->{$method}(); $objectData[$property] = PimPon_Object_Encoder_Default::encode($value); } self::writeDataOnFile($objectData); } if ($object->hasChilds() === true) { array_walk($object->getChilds(), 'PimPon_Object_Export::exportObject'); } }
private function createObject($objectData) { $parentId = $this->rootId; $class = $objectData['class']; $fullPath = $objectData['FullPath'][0]['data'] . '/'; $path = $objectData['Path'][0]['data']; if ($class === self::FOLDER_CLASS) { $object = new $class(); } else { $object = $class::create(); } foreach ($objectData as $property => $values) { if (is_null($values) === true) { continue; } if ($this->isAvailableProperty($property, $object) === false) { continue; } foreach ($values as $value) { $decodeValue = PimPon_Object_Encoder::decode($value); $encodertype = PimPon_Object_Encoder::getCurrentEncoderType(); if ($this->isReference($encodertype) === true) { $reference = new stdClass(); $reference->type = $encodertype; $reference->class = $value['class']; $reference->path = $decodeValue; $this->bindReferencesCollection[$fullPath][$property][] = $reference; } else { $object->{'set' . $property}($decodeValue); } } } if ($this->objectMap[$path] > 0) { $parentId = $this->objectMap[$path]; } $object->setParentId($parentId); $this->objectSave($object); $this->objectMap[$fullPath] = $object->getId(); }
private static function setCurrentEncoderType($type) { self::$currentEncoderType = $type; }