Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/aphront/site/PhabricatorShortSite.php
13441 views
1
<?php
2
3
final 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 (!strlen($uri)) {
18
return null;
19
}
20
21
$phurl_installed = PhabricatorApplication::isClassInstalled(
22
'PhabricatorPhurlApplication');
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('PhabricatorPhurlApplication');
36
37
$maps = array();
38
$maps[] = $this->newRoutingMap()
39
->setApplication($app)
40
->setRoutes($app->getShortRoutes());
41
return $maps;
42
}
43
44
}
45
46