1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Run Maniphest Conduit writes through new editor

Summary: Ref T2217. Swap the editors for the Conduit writes.

Test Plan: Made a bazillion Conduit calls, saw tasks updated appropriately.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

Differential Revision: https://secure.phabricator.com/D7082
This commit is contained in:
epriestley 2013-09-23 14:32:08 -07:00
parent efc7e7cd7e
commit 2bc46f097e
3 changed files with 62 additions and 13 deletions

View file

@ -138,28 +138,27 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod {
$changes[ManiphestTransactionType::TYPE_ATTACH] = $attached;
}
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_CONDUIT,
array());
$template = new ManiphestTransaction();
$template->setContentSource($content_source);
$template->setAuthorPHID($request->getUser()->getPHID());
$template = new ManiphestTransactionPro();
$transactions = array();
foreach ($changes as $type => $value) {
$transaction = clone $template;
$transaction->setTransactionType($type);
$transaction->setNewValue($value);
if ($type == PhabricatorTransactions::TYPE_COMMENT) {
$transaction->setComments($comments);
$transaction->attachComment(
id(new ManiphestTransactionComment())
->setContent($comments));
} else {
$transaction->setNewValue($value);
}
$transactions[] = $transaction;
}
$field_list = PhabricatorCustomField::getObjectFields(
$task,
PhabricatorCustomField::ROLE_EDIT);
$field_list->readFieldsFromStorage($task);
$auxiliary = $request->getValue('auxiliary');
if ($auxiliary) {
@ -196,9 +195,15 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod {
$task = $event->getValue('task');
$transactions = $event->getValue('transactions');
$editor = new ManiphestTransactionEditor();
$editor->setActor($request->getUser());
$editor->setAuxiliaryFields($field_list->getFields());
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_CONDUIT,
array());
$editor = id(new ManiphestTransactionEditorPro())
->setActor($request->getUser())
->setContentSource($content_source)
->setContinueOnNoEffect(true);
$editor->applyTransactions($task, $transactions);
$event = new PhabricatorEvent(

View file

@ -8,6 +8,13 @@ final class ManiphestTransactionEditorPro
$types[] = PhabricatorTransactions::TYPE_COMMENT;
$types[] = ManiphestTransactionPro::TYPE_PRIORITY;
$types[] = ManiphestTransactionPro::TYPE_STATUS;
$types[] = ManiphestTransactionPro::TYPE_TITLE;
$types[] = ManiphestTransactionPro::TYPE_DESCRIPTION;
$types[] = ManiphestTransactionPro::TYPE_OWNER;
$types[] = ManiphestTransactionPro::TYPE_CCS;
$types[] = ManiphestTransactionPro::TYPE_PROJECTS;
$types[] = ManiphestTransactionPro::TYPE_ATTACH;
return $types;
}
@ -18,7 +25,21 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) {
case ManiphestTransactionPro::TYPE_PRIORITY:
return $object->getPriority();
return (int)$object->getPriority();
case ManiphestTransactionPro::TYPE_STATUS:
return (int)$object->getStatus();
case ManiphestTransactionPro::TYPE_TITLE:
return $object->getTitle();
case ManiphestTransactionPro::TYPE_DESCRIPTION:
return $object->getDescription();
case ManiphestTransactionPro::TYPE_OWNER:
return $object->getOwnerPHID();
case ManiphestTransactionPro::TYPE_CCS:
return $object->getCCPHIDs();
case ManiphestTransactionPro::TYPE_PROJECTS:
return $object->getProjectPHIDs();
case ManiphestTransactionPro::TYPE_ATTACH:
return $object->getAttached();
}
}
@ -29,6 +50,14 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) {
case ManiphestTransactionPro::TYPE_PRIORITY:
case ManiphestTransactionPro::TYPE_STATUS:
return (int)$xaction->getNewValue();
case ManiphestTransactionPro::TYPE_TITLE:
case ManiphestTransactionPro::TYPE_DESCRIPTION:
case ManiphestTransactionPro::TYPE_OWNER:
case ManiphestTransactionPro::TYPE_CCS:
case ManiphestTransactionPro::TYPE_PROJECTS:
case ManiphestTransactionPro::TYPE_ATTACH:
return $xaction->getNewValue();
}
@ -41,6 +70,20 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) {
case ManiphestTransactionPro::TYPE_PRIORITY:
return $object->setPriority($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_STATUS:
return $object->setStatus($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_TITLE:
return $object->setTitle($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_DESCRIPTION:
return $object->setDescription($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_OWNER:
return $object->setOwnerPHID($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_CCS:
return $object->setCCPHIDs($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_PROJECTS:
return $object->setProjectPHIDs($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_ATTACH:
return $object->setAttached($xaction->getNewValue());
}
}

View file

@ -272,6 +272,7 @@ abstract class PhabricatorStandardCustomField
if ($this->getRequired()) {
$value = $this->getOldValueForApplicationTransactions();
$transaction = null;
foreach ($xactions as $xaction) {
$value = $xaction->getNewValue();