Differential D11050 Diff 26532 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-Z0-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) { | ||||
| $id_map = array(); | $callsigns = array(); $ids = array(); | ||||
| foreach ($names as $name) { | foreach ($names as $name) { | ||||
| $id = substr($name, 1); | $id = substr($name, 1); | ||||
| $id_map[$id][] = $name; | if (is_numeric($id)) { | ||||
| $ids[] = $id; | |||||
| } else { | |||||
| $callsigns[] = $id; | |||||
| } | |||||
| } | } | ||||
| $results = array(); | |||||
| if ($callsigns) { | |||||
| $objects = id(new PhabricatorRepositoryQuery()) | $objects = id(new PhabricatorRepositoryQuery()) | ||||
| ->setViewer($query->getViewer()) | ->setViewer($query->getViewer()) | ||||
| ->withCallsigns(array_keys($id_map)) | ->withCallsigns($callsigns) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($objects as $object) { | |||||
| $results[$object->getCallsign()] = $object; | |||||
| } | |||||
| } | |||||
| $results = array(); | if ($ids) { | ||||
| $objects = id(new PhabricatorRepositoryQuery()) | |||||
| ->setViewer($query->getViewer()) | |||||
| ->withIDs($ids) | |||||
| ->execute(); | |||||
| foreach ($objects as $object) { | foreach ($objects as $object) { | ||||
| $callsign = $object->getCallsign(); | $results[$object->getID()] = $object; | ||||
| foreach (idx($id_map, $callsign, array()) as $name) { | |||||
| $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; | ||||
| } | } | ||||
| } | } | ||||
On the r vs R thing, this would just become something like /^(?:r[A-Z]+|R[0-9]+)$/, I think.