/**
  * {@inheritdoc}
  */
 public function commit(TreeInterface $tree, UserInterface $user, $message = '', CommitInterface $parentCommit = null)
 {
     $commit = new Commit();
     $commit->setPolicyCollection(new PolicyCollection());
     $commit->setCommitter($user);
     $commit->setParentCommit($parentCommit);
     $commit->setCreatedAt(new \DateTime());
     $commit->setMessage($message);
     $commit->setTree($tree);
     return $this->database->store($commit);
 }
 /**
  * @param $data
  *
  * @return ChunkInterface
  */
 public function upload($data)
 {
     $chunk = new Chunk();
     $chunk->setData($data);
     $chunk->setLength(strlen($data));
     $chunk->setPolicyCollection(new PolicyCollection());
     $chunk->setHash($this->factory->createHash($data));
     if ($this->database->contains($chunk->getHash(), Chunk::class)) {
         return $chunk;
     }
     return $this->database->store($chunk, array(ReplicatorInterface::OPTION_NAME => ReplicatorInterface::TYPE_FULL));
 }
 /**
  * @param TreeNodeInterface $child
  */
 private function storeNode(TreeNodeInterface $child)
 {
     $this->database->store($child);
     $this->cache->save($child->getHash(), $child);
 }
 /**
  * {@inheritdoc}
  */
 public function update(ReferenceInterface $reference, CommitInterface $commit)
 {
     $reference->update($commit);
     return $this->database->store($reference);
 }