Esempio n. 1
0
 public function unserialize($data)
 {
     $params = new ArrayCollection(json_decode($data, true));
     if ($params->count() === 1 && $params->containsKey('data')) {
         $data = $params['data'];
         if ($this->nativeUnserialize($data, $unserialized)) {
             return $unserialized;
         }
     }
     if ($params->containsKey('class')) {
         /** @var ISerializable|string $cls */
         $cls = $params['class'];
         if (!class_exists($cls)) {
             throw new NotSerializableException($cls . ' does not exist');
         }
         return $cls::fromArray($params->toArray());
     }
     foreach ($params as $key => $value) {
         if (is_string($value)) {
             $value = trim($value);
             if ($this->nativeUnserialize($value, $data)) {
                 $value = $data;
             }
             $params[$key] = $value;
         } elseif (is_array($value) && array_key_exists('class', $value)) {
             /** @var ISerializable|string $cls */
             $cls = $value['class'];
             if (!class_exists($cls)) {
                 throw new NotSerializableException($cls . ' does not exist');
             }
             $params[$key] = $cls::fromArray($value);
         }
     }
     return $params;
 }
Esempio n. 2
0
 public function getMessages($channel)
 {
     if (!$this->pubSub->containsKey($channel)) {
         return new ArrayCollection();
     }
     return $this->pubSub[$channel];
 }