Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phid / resolver / PhabricatorPHIDResolver.php
blob940221f5513eff909cc211d0a076abfd20145148
1 <?php
3 /**
4 * Resolve a list of identifiers into PHIDs.
6 * This class simplifies the process of converting a list of mixed token types
7 * (like some PHIDs and some usernames) into a list of just PHIDs.
8 */
9 abstract class PhabricatorPHIDResolver extends Phobject {
11 private $viewer;
13 final public function setViewer(PhabricatorUser $viewer) {
14 $this->viewer = $viewer;
15 return $this;
18 final public function getViewer() {
19 return $this->viewer;
22 final public function resolvePHIDs(array $phids) {
23 $type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
25 $names = array();
26 foreach ($phids as $key => $phid) {
27 if (phid_get_type($phid) == $type_unknown) {
28 $names[$key] = $phid;
32 if ($names) {
33 $map = $this->getResolutionMap($names);
34 foreach ($names as $key => $name) {
35 if (isset($map[$name])) {
36 $phids[$key] = $map[$name];
41 return $phids;
44 abstract protected function getResolutionMap(array $names);