예제 #1
0
 public static function unserialize(\stdClass $data, $entityFactory, ContentStreamConverter $converter)
 {
     $entityMeta = $entityFactory->getEntityMeta();
     foreach ($data as $property => $value) {
         $propertyMeta = $entityMeta->getPropertyMeta($property);
         $propertyType = $propertyMeta->getType();
         if ($propertyType instanceof EntityType) {
             if ($propertyType->implementsInterface('Psc\\TPL\\ContentStream\\ContextLoadable')) {
                 $objectClass = $propertyType->getGClass()->getFQN();
                 $value = $objectClass::loadWithContentStreamContext($value, $converter->getContext());
             } elseif ($propertyType->isCSEntry()) {
                 if (is_string($value) && trim($value) === '') {
                     $value = NULL;
                 } else {
                     $serialized = (object) $value;
                     $serialized->type = $propertyType->getGClass()->getClassName();
                     $value = $converter->unserializeEntry($serialized);
                 }
             } else {
                 throw new \RuntimeException(sprintf("Cannot convert EntityType: %s in property '%s' from Entity %s", $propertyType->getClassFQN(), $property, $entityMeta->getClass()));
             }
         }
         $entityFactory->set($property, $value);
     }
     return $entityFactory->getEntity();
 }
예제 #2
0
 public static function unserialize(\stdClass $data, $entityFactory, Converter $converter)
 {
     $contentStream = self::create($data->locale, isset($data->type) ? $data->type : NULL, isset($data->revision) ? $data->revision : NULL, isset($data->slug) ? $data->slug : NULL);
     $converter->convertUnserialized($data->entries, $contentStream);
     return $contentStream;
 }