2013-05-31 01:37:51 +02:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class ConpherenceCreateThreadConduitAPIMethod
|
|
|
|
extends ConpherenceConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'conpherence.createthread';
|
|
|
|
}
|
2013-05-31 01:37:51 +02:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2013-05-31 19:43:46 +02:00
|
|
|
return pht('Create a new conpherence thread.');
|
2013-05-31 01:37:51 +02:00
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineParamTypes() {
|
2013-05-31 01:37:51 +02:00
|
|
|
return array(
|
|
|
|
'title' => 'optional string',
|
|
|
|
'message' => 'required string',
|
2014-10-07 15:01:04 +02:00
|
|
|
'participantPHIDs' => 'required list<phids>',
|
2013-05-31 01:37:51 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineReturnType() {
|
2013-05-31 01:37:51 +02:00
|
|
|
return 'nonempty dict';
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineErrorTypes() {
|
2013-05-31 01:37:51 +02:00
|
|
|
return array(
|
2013-05-31 19:43:46 +02:00
|
|
|
'ERR_EMPTY_PARTICIPANT_PHIDS' => pht(
|
|
|
|
'You must specify participant phids.'),
|
|
|
|
'ERR_EMPTY_MESSAGE' => pht(
|
2014-10-07 15:01:04 +02:00
|
|
|
'You must specify a message.'),
|
2013-05-31 01:37:51 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$participant_phids = $request->getValue('participantPHIDs', array());
|
|
|
|
$message = $request->getValue('message');
|
|
|
|
$title = $request->getValue('title');
|
|
|
|
|
2015-03-26 21:35:48 +01:00
|
|
|
list($errors, $conpherence) = ConpherenceEditor::createThread(
|
2013-05-31 01:37:51 +02:00
|
|
|
$request->getUser(),
|
|
|
|
$participant_phids,
|
|
|
|
$title,
|
|
|
|
$message,
|
2016-03-25 13:56:16 +01:00
|
|
|
$request->newContentSource());
|
2013-05-31 01:37:51 +02:00
|
|
|
|
|
|
|
if ($errors) {
|
|
|
|
foreach ($errors as $error_code) {
|
|
|
|
switch ($error_code) {
|
|
|
|
case ConpherenceEditor::ERROR_EMPTY_MESSAGE:
|
|
|
|
throw new ConduitException('ERR_EMPTY_MESSAGE');
|
|
|
|
break;
|
|
|
|
case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
|
|
|
|
throw new ConduitException('ERR_EMPTY_PARTICIPANT_PHIDS');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
2013-05-31 19:43:46 +02:00
|
|
|
'conpherenceID' => $conpherence->getID(),
|
2013-05-31 01:37:51 +02:00
|
|
|
'conpherencePHID' => $conpherence->getPHID(),
|
2014-07-10 00:12:48 +02:00
|
|
|
'conpherenceURI' => $this->getConpherenceURI($conpherence),
|
|
|
|
);
|
2013-05-31 01:37:51 +02:00
|
|
|
}
|
2014-07-10 00:12:48 +02:00
|
|
|
|
2013-05-31 01:37:51 +02:00
|
|
|
}
|