listing all pastes works
[phorkie.git] / src / Phorkie / Repository.php
index f23db7e17faea3f6d7569b27b1c7d9bd11da0fb1..aeccc72f826107a2465a4a9d4023490bc6b83175 100644 (file)
@@ -42,6 +42,20 @@ class Repository
         $this->repoDir = $repoDir;
     }
 
+    public function loadById($id)
+    {
+        if (!is_numeric($id)) {
+            throw new Exception_Input('Paste ID not numeric');
+        }
+        $this->id = (int)$id;
+
+        $repoDir = $GLOBALS['phorkie']['cfg']['repos'] . '/' . $this->id;
+        if (!is_dir($repoDir)) {
+            throw new Exception_NotFound('Paste not found');
+        }
+        $this->repoDir = $repoDir;
+    }
+
     public function getVc()
     {
         return new \VersionControl_Git($this->repoDir);