/**
  * @param string $encoded
  * @return Request
  * @throws MessageTransformerException
  */
 public function decodeRequest($encoded)
 {
     $message = $this->decodeMessage($encoded);
     if (!$message instanceof Request) {
         throw new MessageTransformerException('Message should be instance of Request');
     }
     $string = $message->getClosure();
     $closure = $this->serializer->unserialize($string);
     return new Request($closure);
 }
示例#2
0
 /**
  * Parse the json decode to convert to objects again
  *
  * @param mixed $value
  * @return mixed
  */
 protected function unserializeData($value)
 {
     if (is_scalar($value) || $value === null) {
         return $value;
     }
     if (isset($value[static::CLASS_IDENTIFIER_KEY])) {
         return $this->unserializeObject($value);
     }
     if (!empty($value[static::CLOSURE_IDENTIFIER_KEY])) {
         if (!$this->closureSerializer) {
             throw new JsonSerializerException('Closure serializer not provided to unserialize closure');
         }
         return $this->closureSerializer->unserialize($value['value']);
     }
     return array_map(array($this, __FUNCTION__), $value);
 }
示例#3
0
 /**
  * @param mixed $data
  * @return CommandInterface
  */
 public function setData($data)
 {
     $this->closure = $this->serializer->unserialize($data);
     return $this;
 }