Page MenuHomePhabricator

D9642.diff
No OneTemporary

D9642.diff

diff --git a/src/applications/phriction/conduit/ConduitAPI_phriction_new_Method.php b/src/applications/phriction/conduit/ConduitAPI_phriction_new_Method.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/conduit/ConduitAPI_phriction_new_Method.php
@@ -0,0 +1,48 @@
+<?php
+
+final class ConduitAPI_phriction_new_Method
+ extends ConduitAPI_phriction_Method {
+
+ public function getMethodDescription() {
+ return 'Create a Phriction document.';
+ }
+
+ public function defineParamTypes() {
+ return array(
+ 'slug' => 'required string',
+ 'title' => 'optional string',
+ 'content' => 'optional string',
+ 'description' => 'optional string',
+ );
+ }
+
+ public function defineReturnType() {
+ return 'nonempty dict';
+ }
+
+ public function defineErrorTypes() {
+ return array(
+ );
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $slug = $request->getValue('slug');
+
+ $doc = id(new PhrictionDocumentQuery())
+ ->setViewer($request->getUser())
+ ->withSlugs(array(PhabricatorSlug::normalize($slug)))
+ ->executeOne();
+ if ($doc) {
+ throw new Exception(pht('Document already exists.'));
+ }
+
+ $editor = id(PhrictionDocumentEditor::newForSlug($slug))
+ ->setActor($request->getUser())
+ ->setTitle($request->getValue('title'))
+ ->setContent($request->getValue('content'))
+ ->setDescription($request->getvalue('description'))
+ ->save();
+
+ return $this->buildDocumentInfoDictionary($editor->getDocument());
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 30, 1:59 PM (5 d, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6726830
Default Alt Text
D9642.diff (1 KB)

Event Timeline