Differential D11050 Diff 26555 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(); | $results = id(new PhabricatorRepositoryQuery()) | ||||
| foreach ($names as $name) { | |||||
| $id = substr($name, 1); | |||||
| $id_map[$id][] = $name; | |||||
| } | |||||
| $objects = id(new PhabricatorRepositoryQuery()) | |||||
| ->setViewer($query->getViewer()) | ->setViewer($query->getViewer()) | ||||
| ->withCallsigns(array_keys($id_map)) | ->withIdentifiers($names) | ||||
| ->execute(); | ->execute(); | ||||
| // We don't use the associative result here as this changes the API | |||||
| $results = array(); | // even though it might be more appropriate | ||||
| foreach ($objects as $object) { | |||||
| $callsign = $object->getCallsign(); | |||||
| 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.