Example #1
0
 /**
  * @return Node[]
  */
 public function getChildren()
 {
     $children = array();
     foreach ($this->reference->getCommit()->getTree()->getChildren() as $name => $child) {
         if ($child->getType() === TreeNodeInterface::TREE_TYPE && ($this->depth > 0 || $this->depth === -1)) {
             $children[$name] = new Directory($child, $name, $this->getHash(), $this->depth === -1 ? $this->depth : $this->depth - 1);
         } elseif ($child->getType() === TreeNodeInterface::FILE_TYPE) {
             $children[$name] = new File($child, $name, $this->getHash());
         }
         // TODO TreeReferenceInterface
     }
     return $children;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getRoot(CommitInterface $commit = null)
 {
     if ($commit !== null) {
         return $commit->getTree();
     }
     if (!$this->reference) {
         if ($this->referenceHash === null) {
             return;
         }
         try {
             $this->reference = $this->referenceManager->fetch($this->referenceHash);
         } catch (\Exception $ex) {
             return;
         }
         $this->referenceCommit = $this->reference->getCommit();
     }
     if (!$this->root) {
         $this->root = $this->referenceCommit->getTree();
     }
     return $this->root;
 }
 /**
  * {@inheritdoc}
  */
 public function update(ReferenceInterface $reference, CommitInterface $commit)
 {
     $reference->update($commit);
     return $this->database->store($reference);
 }