1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-03 20:22:46 +01:00
phorge-phorge/src/applications/conpherence/conduit/ConpherenceCreateThreadConduitAPIMethod.php
Joshua Spence 3cf9a5820f Minor formatting changes
Summary: Apply some autofix linter rules.

Test Plan: `arc lint` and `arc unit`

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin, hach-que

Differential Revision: https://secure.phabricator.com/D10585
2014-10-08 08:39:49 +11:00

67 lines
1.8 KiB
PHP

<?php
final class ConpherenceCreateThreadConduitAPIMethod
extends ConpherenceConduitAPIMethod {
public function getAPIMethodName() {
return 'conpherence.createthread';
}
public function getMethodDescription() {
return pht('Create a new conpherence thread.');
}
public function defineParamTypes() {
return array(
'title' => 'optional string',
'message' => 'required string',
'participantPHIDs' => 'required list<phids>',
);
}
public function defineReturnType() {
return 'nonempty dict';
}
public function defineErrorTypes() {
return array(
'ERR_EMPTY_PARTICIPANT_PHIDS' => pht(
'You must specify participant phids.'),
'ERR_EMPTY_MESSAGE' => pht(
'You must specify a message.'),
);
}
protected function execute(ConduitAPIRequest $request) {
$participant_phids = $request->getValue('participantPHIDs', array());
$message = $request->getValue('message');
$title = $request->getValue('title');
list($errors, $conpherence) = ConpherenceEditor::createConpherence(
$request->getUser(),
$participant_phids,
$title,
$message,
PhabricatorContentSource::newFromConduitRequest($request));
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(
'conpherenceID' => $conpherence->getID(),
'conpherencePHID' => $conpherence->getPHID(),
'conpherenceURI' => $this->getConpherenceURI($conpherence),
);
}
}