mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-23 21:18:19 +01:00
621f806e3b
Summary: Ref T9132. This allows you to prefill EditEngine forms with stuff like `?subscribers=epriestley`, and we'll figure out what you mean. Test Plan: - Did `/?subscribers=...` with various values (good, bad, mis-capitalized). - Did `/?projects=...` with various values (good, bad, mis-capitalized). - Reviewed documentation. - Reviewed {nav Config > HTTP Parameter Types}. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9132 Differential Revision: https://secure.phabricator.com/D14404
46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Resolve a list of identifiers into PHIDs.
|
|
*
|
|
* This class simplifies the process of convering a list of mixed token types
|
|
* (like some PHIDs and some usernames) into a list of just PHIDs.
|
|
*/
|
|
abstract class PhabricatorPHIDResolver extends Phobject {
|
|
|
|
private $viewer;
|
|
|
|
final public function setViewer(PhabricatorUser $viewer) {
|
|
$this->viewer = $viewer;
|
|
return $this;
|
|
}
|
|
|
|
final public function getViewer() {
|
|
return $this->viewer;
|
|
}
|
|
|
|
final public function resolvePHIDs(array $phids) {
|
|
$type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
|
|
|
|
$names = array();
|
|
foreach ($phids as $key => $phid) {
|
|
if (phid_get_type($phid) == $type_unknown) {
|
|
$names[$key] = $phid;
|
|
}
|
|
}
|
|
|
|
if ($names) {
|
|
$map = $this->getResolutionMap($names);
|
|
foreach ($names as $key => $name) {
|
|
if (isset($map[$name])) {
|
|
$phids[$key] = $map[$name];
|
|
}
|
|
}
|
|
}
|
|
|
|
return $phids;
|
|
}
|
|
|
|
abstract protected function getResolutionMap(array $names);
|
|
|
|
}
|