NOTE(rmarin): Because thrift_protocol_write_binary adds a begin message prefix, you cannot specify a transport in which to serialize an object. It has to be a string. Otherwise we will break the compatibility with normal deserialization.
($object)
| 39 | // be a string. Otherwise we will break the compatibility with |
| 40 | // normal deserialization. |
| 41 | public static function serialize($object) |
| 42 | { |
| 43 | $transport = new TMemoryBuffer(); |
| 44 | $protocol = new TBinaryProtocolAccelerated($transport); |
| 45 | if (function_exists('thrift_protocol_write_binary')) { |
| 46 | thrift_protocol_write_binary( |
| 47 | $protocol, |
| 48 | $object->getName(), |
| 49 | TMessageType::REPLY, |
| 50 | $object, |
| 51 | 0, |
| 52 | $protocol->isStrictWrite() |
| 53 | ); |
| 54 | |
| 55 | $protocol->readMessageBegin($unused_name, $unused_type, $unused_seqid); |
| 56 | } else { |
| 57 | $object->write($protocol); |
| 58 | } |
| 59 | $protocol->getTransport()->flush(); |
| 60 | |
| 61 | return $transport->getBuffer(); |
| 62 | } |
| 63 | |
| 64 | public static function deserialize($string_object, $class_name, $buffer_size = 8192) |
| 65 | { |