Differential D18467 Diff 44370 src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | if ($xactions) { | ||||
$comment_map = msort($comment_map, 'getCommentVersion'); | $comment_map = msort($comment_map, 'getCommentVersion'); | ||||
$comment_map = array_reverse($comment_map); | $comment_map = array_reverse($comment_map); | ||||
$comment_map = mgroup($comment_map, 'getTransactionPHID'); | $comment_map = mgroup($comment_map, 'getTransactionPHID'); | ||||
} else { | } else { | ||||
$comment_map = array(); | $comment_map = array(); | ||||
} | } | ||||
$modular_classes = array(); | |||||
$modular_objects = array(); | |||||
$modular_xactions = array(); | |||||
foreach ($xactions as $xaction) { | |||||
if (!$xaction instanceof PhabricatorModularTransaction) { | |||||
continue; | |||||
} | |||||
$modular_template = $xaction->getModularType(); | |||||
$modular_class = get_class($modular_template); | |||||
if (!isset($modular_objects[$modular_class])) { | |||||
try { | |||||
$modular_object = newv($modular_class, array()); | |||||
$modular_objects[$modular_class] = $modular_object; | |||||
} catch (Exception $ex) { | |||||
continue; | |||||
} | |||||
} | |||||
$modular_classes[$xaction->getPHID()] = $modular_class; | |||||
$modular_xactions[$modular_class][] = $xaction; | |||||
} | |||||
$modular_data_map = array(); | |||||
foreach ($modular_objects as $class => $modular_type) { | |||||
$modular_data_map[$class] = $modular_type | |||||
->setViewer($viewer) | |||||
->loadTransactionTypeConduitData($modular_xactions[$class]); | |||||
} | |||||
$data = array(); | $data = array(); | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
$comments = idx($comment_map, $xaction->getPHID()); | $comments = idx($comment_map, $xaction->getPHID()); | ||||
$comment_data = array(); | $comment_data = array(); | ||||
if ($comments) { | if ($comments) { | ||||
$removed = head($comments)->getIsDeleted(); | $removed = head($comments)->getIsDeleted(); | ||||
Show All 21 Lines | foreach ($xactions as $xaction) { | ||||
'dateModified' => (int)$comment->getDateModified(), | 'dateModified' => (int)$comment->getDateModified(), | ||||
'removed' => (bool)$comment->getIsDeleted(), | 'removed' => (bool)$comment->getIsDeleted(), | ||||
'content' => $content, | 'content' => $content, | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
$fields = array(); | $fields = array(); | ||||
$type = null; | |||||
if (isset($modular_classes[$xaction->getPHID()])) { | |||||
$modular_class = $modular_classes[$xaction->getPHID()]; | |||||
$modular_object = $modular_objects[$modular_class]; | |||||
$modular_data = $modular_data_map[$modular_class]; | |||||
$type = $modular_object->getTransactionTypeForConduit($xaction); | |||||
$fields = $modular_object->getFieldValuesForConduit( | |||||
$xaction, | |||||
$modular_data); | |||||
} | |||||
if (!$fields) { | if (!$fields) { | ||||
$fields = (object)$fields; | $fields = (object)$fields; | ||||
} | } | ||||
$data[] = array( | $data[] = array( | ||||
'id' => (int)$xaction->getID(), | 'id' => (int)$xaction->getID(), | ||||
'phid' => (string)$xaction->getPHID(), | 'phid' => (string)$xaction->getPHID(), | ||||
'type' => $type, | |||||
'authorPHID' => (string)$xaction->getAuthorPHID(), | 'authorPHID' => (string)$xaction->getAuthorPHID(), | ||||
'objectPHID' => (string)$xaction->getObjectPHID(), | 'objectPHID' => (string)$xaction->getObjectPHID(), | ||||
'dateCreated' => (int)$xaction->getDateCreated(), | 'dateCreated' => (int)$xaction->getDateCreated(), | ||||
'dateModified' => (int)$xaction->getDateModified(), | 'dateModified' => (int)$xaction->getDateModified(), | ||||
'comments' => $comment_data, | 'comments' => $comment_data, | ||||
'fields' => $fields, | 'fields' => $fields, | ||||
); | ); | ||||
} | } | ||||
$results = array( | $results = array( | ||||
'data' => $data, | 'data' => $data, | ||||
); | ); | ||||
return $this->addPagerResults($results, $pager); | return $this->addPagerResults($results, $pager); | ||||
} | } | ||||
} | } |