@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorShortSite extends PhabricatorSite {
4
5 public function getDescription() {
6 return pht('Serves shortened URLs.');
7 }
8
9 public function getPriority() {
10 return 2500;
11 }
12
13 public function newSiteForRequest(AphrontRequest $request) {
14 $host = $request->getHost();
15
16 $uri = PhabricatorEnv::getEnvConfig('phurl.short-uri');
17 if (!phutil_nonempty_string($uri)) {
18 return null;
19 }
20
21 $phurl_installed = PhabricatorApplication::isClassInstalled(
22 PhabricatorPhurlApplication::class);
23 if (!$phurl_installed) {
24 return false;
25 }
26
27 if ($this->isHostMatch($host, array($uri))) {
28 return new PhabricatorShortSite();
29 }
30
31 return null;
32 }
33
34 public function getRoutingMaps() {
35 $app = PhabricatorApplication::getByClass(
36 PhabricatorPhurlApplication::class);
37
38 $maps = array();
39 $maps[] = $this->newRoutingMap()
40 ->setApplication($app)
41 ->setRoutes($app->getShortRoutes());
42 return $maps;
43 }
44
45}