Differential D11050 Diff 26532 src/applications/diffusion/remarkup/DiffusionRepositoryRemarkupRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/remarkup/DiffusionRepositoryRemarkupRule.php
| <?php | <?php | ||||
| final class DiffusionRepositoryRemarkupRule | final class DiffusionRepositoryRemarkupRule | ||||
| extends PhabricatorObjectRemarkupRule { | extends PhabricatorObjectRemarkupRule { | ||||
| protected function getObjectNamePrefix() { | protected function getObjectNamePrefix() { | ||||
| return 'r'; | return 'r'; | ||||
| } | } | ||||
| protected function getObjectIDPattern() { | protected function getObjectIDPattern() { | ||||
| return '[A-Z]+'; | return '[A-Z0-9]+'; | ||||
| } | } | ||||
| protected function loadObjects(array $ids) { | protected function loadObjects(array $ids) { | ||||
| $viewer = $this->getEngine()->getConfig('viewer'); | $viewer = $this->getEngine()->getConfig('viewer'); | ||||
| $repositories = id(new PhabricatorRepositoryQuery()) | $repo_ids = array(); $callsigns = array(); | ||||
| foreach ($ids as $id) { | |||||
| if (is_numeric($id)) { | |||||
| $repo_ids[] = $id; | |||||
| } else { | |||||
| $callsigns[] = $id; | |||||
| } | |||||
| } | |||||
| $results = array(); | |||||
| if ($callsigns) { | |||||
| $objects = id(new PhabricatorRepositoryQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withCallsigns($callsigns) | |||||
| ->execute(); | |||||
| foreach ($objects as $object) { | |||||
| $results[$object->getCallsign()] = $object; | |||||
| } | |||||
| } | |||||
| if ($repo_ids) { | |||||
| $objects = id(new PhabricatorRepositoryQuery()) | |||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withCallsigns($ids) | ->withIDs($repo_ids) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($objects as $object) { | |||||
| $results[$object->getID()] = $object; | |||||
| } | |||||
| } | |||||
| return mpull($repositories, null, 'getCallsign'); | return $results; | ||||
| } | } | ||||
| } | } | ||||