/**
  * Adds an object to the persistent data store.
  *
  * @param \SmashPig\Core\DataStores\KeyedOpaqueStorableObject $obj
  *
  * @throws \SmashPig\Core\DataStores\DataStoreException if the message could not be stored.
  * @return null
  */
 public function addObject(KeyedOpaqueStorableObject $obj)
 {
     $keys = $obj->getObjectKeys();
     // FIXME magic string is magic
     if (!array_key_exists('correlationId', $keys)) {
         throw new DataStoreException("Required property correlationId was not exposed.");
     }
     $corrId = $keys['correlationId'];
     if (!isset($this->messages[$corrId])) {
         $this->messages[$corrId] = array();
     }
     array_push($this->messages[$corrId], $obj);
 }
 /**
  * Adds an object to the persistent data store.
  *
  * @param KeyedOpaqueStorableObject $obj
  *
  * @throws DataStoreException if the message could not be stored.
  * @return null
  */
 public function addObject(KeyedOpaqueStorableObject $obj)
 {
     $keys = $obj->getObjectKeys();
     $objFileName = $this->constructFileName(Context::get()->getContextId(), $keys, $this->insertCount++);
     $objFsPath = $this->basePath . '/objects/' . $objFileName;
     /* --- Create the root object file --- */
     if (file_exists($objFsPath) || ($fptr = fopen($objFsPath, 'xb')) === false) {
         throw new DataStoreException("Could not add object to store! Fully qualified key '{$objFileName}' already exists!");
     }
     fwrite($fptr, get_class($obj));
     fwrite($fptr, "\n");
     fwrite($fptr, $obj->toJson());
     fclose($fptr);
     /* === Create the helper linking files === */
     /* --- Class file first --- */
     $this->addKeyedLinkingFile('class', get_class($obj), $objFileName, $objFsPath);
     /* --- Everything else --- */
     foreach ($keys as $key => $value) {
         $this->addKeyedLinkingFile($key, $value, $objFileName, $objFsPath);
     }
 }