Differential D11050 Diff 26716 src/applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php
Show All 38 Lines | foreach ($handles as $phid => $handle) { | ||||
$handle->setName($monogram); | $handle->setName($monogram); | ||||
$handle->setFullName("{$monogram} {$name}"); | $handle->setFullName("{$monogram} {$name}"); | ||||
$handle->setURI("/diffusion/{$callsign}/"); | $handle->setURI("/diffusion/{$callsign}/"); | ||||
} | } | ||||
} | } | ||||
public function canLoadNamedObject($name) { | public function canLoadNamedObject($name) { | ||||
return preg_match('/^r[A-Z]+$/', $name); | return preg_match('/^r[A-Z]+|R[0-9]+$/', $name); | ||||
epriestley: On the `r` vs `R` thing, this would just become something like `/^(?:r[A-Z]+|R[0-9]+)$/`, I… | |||||
} | } | ||||
public function loadNamedObjects( | public function loadNamedObjects( | ||||
PhabricatorObjectQuery $query, | PhabricatorObjectQuery $query, | ||||
array $names) { | array $names) { | ||||
$results = array(); | |||||
$id_map = array(); | $id_map = array(); | ||||
foreach ($names as $name) { | foreach ($names as $key => $name) { | ||||
$id = substr($name, 1); | $id = substr($name, 1); | ||||
$id_map[$id][] = $name; | $id_map[$id][] = $name; | ||||
$names[$key] = substr($name, 1); | |||||
} | } | ||||
$objects = id(new PhabricatorRepositoryQuery()) | $query = id(new PhabricatorRepositoryQuery()) | ||||
->setViewer($query->getViewer()) | ->setViewer($query->getViewer()) | ||||
->withCallsigns(array_keys($id_map)) | ->withIdentifiers($names); | ||||
->execute(); | |||||
$results = array(); | if ($query->execute()) { | ||||
foreach ($objects as $object) { | $objects = $query->getIdentifierMap(); | ||||
$callsign = $object->getCallsign(); | foreach ($objects as $key => $object) { | ||||
foreach (idx($id_map, $callsign, array()) as $name) { | foreach (idx($id_map, $key, array()) as $name) | ||||
$results[$name] = $object; | $results[$name] = $object; | ||||
} | } | ||||
} | |||||
Not Done Inline ActionsIt looks like removing this code might incorrectly remove the "r" from the result map? epriestley: It looks like removing this code might incorrectly remove the "r" from the result map? | |||||
return $results; | return $results; | ||||
} else { | |||||
return array(); | |||||
} | |||||
} | } | ||||
} | } |
On the r vs R thing, this would just become something like /^(?:r[A-Z]+|R[0-9]+)$/, I think.