Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/phid/DifferentialDiffPHIDType.php
Show All 33 Lines | foreach ($handles as $phid => $handle) { | ||||
$id = $diff->getID(); | $id = $diff->getID(); | ||||
$handle->setName(pht('Diff %d', $id)); | $handle->setName(pht('Diff %d', $id)); | ||||
$handle->setURI("/differential/diff/{$id}/"); | $handle->setURI("/differential/diff/{$id}/"); | ||||
} | } | ||||
} | } | ||||
public function canLoadNamedObject($name) { | |||||
return preg_match('/^Diff [1-9]\d*$/i', $name); | |||||
} | |||||
public function loadNamedObjects( | |||||
PhabricatorObjectQuery $query, | |||||
array $names) { | |||||
$id_map = array(); | |||||
foreach ($names as $name) { | |||||
$id = (int)substr($name, 5); | |||||
$id_map[$id][] = $name; | |||||
} | |||||
$objects = id(new DifferentialDiffQuery()) | |||||
->setViewer($query->getViewer()) | |||||
->withIDs(array_keys($id_map)) | |||||
->execute(); | |||||
$results = array(); | |||||
foreach ($objects as $id => $object) { | |||||
foreach (idx($id_map, $id, array()) as $name) { | |||||
$results[$name] = $object; | |||||
} | |||||
} | |||||
return $results; | |||||
} | |||||
} | } |