def object_hook(class_name, data): reg = {'Album': Album, 'AlbumItem': AlbumItem, 'Image': Image} clazz = reg.get(class_name) if not clazz: return phpobject(class_name, data) return clazz(**data)
def object_hook(obj): if isinstance(obj, Logger): return phpobject( 'Logger', { b'\x00Logger\x00initMsg': obj.initMsg, b'\x00Logger\x00exitMsg': obj.exitMsg, b'\x00Logger\x00logFile': obj.logFile })
def to_php(self): """ PHP representation :return: """ js = collections.OrderedDict() js['socket'] = None obj = phpserialize.phpobject('App\\Events\\TesterJobProgress', js) util.php_set_protected(obj, 'json_data', json.dumps(self.json_data)) return obj
def to_php(self): """ php serialization :return: """ js = collections.OrderedDict() js['class'] = self.cls js['method'] = self.method js['data'] = [util.phpize(x) for x in self.data] js['tries'] = self.tries js['timeout'] = self.timeout obj = phpserialize.phpobject(self.invoker, js) util.php_set_protected(obj, 'job', None) return obj
def dump_object_hook(obj): if isinstance(obj, User): return phpserialize.phpobject('WP_User', {'username': obj.username}) raise LookupError('unknown object')