Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14008001
D9642.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D9642.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D9642: Add phriction.new conduit endpoint
Attached
Detach File
Event Timeline
Log In to Comment