mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
bcc5e55af2
Summary: This enables CORGI. Currently, `AphrontSite` subclasses can't really have their own routes. They can do this sort of hacky rewriting of paths, but that's a mess and not desirable in the long run. Instead, let subclasses build their own routing maps. This will let CORP and ORG have their own routing maps. I was able to get rid of the `PhameBlogResourcesSite` since it can really just share the standard resources site. Test Plan: - With no base URI set, and a base URI set, loaded main page and resources (from main site). - With file domain set, loaded resources from main site and file site. - Loaded a skinned blog from a domain. - Loaded a skinned blog from the main site. - Viewed "Request" tab of DarkConsole to see site/controller info. Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D14008
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorPlatformSite extends PhabricatorSite {
|
|
|
|
public function getDescription() {
|
|
return pht('Serves the core platform and applications.');
|
|
}
|
|
|
|
public function getPriority() {
|
|
return 1000;
|
|
}
|
|
|
|
public function newSiteForRequest(AphrontRequest $request) {
|
|
// If no base URI has been configured yet, match this site so the user
|
|
// can follow setup instructions.
|
|
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
|
if (!strlen($base_uri)) {
|
|
return new PhabricatorPlatformSite();
|
|
}
|
|
|
|
$uris = array();
|
|
$uris[] = $base_uri;
|
|
$uris[] = PhabricatorEnv::getEnvConfig('phabricator.production-uri');
|
|
|
|
$allowed = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris');
|
|
if ($allowed) {
|
|
foreach ($allowed as $uri) {
|
|
$uris[] = $uri;
|
|
}
|
|
}
|
|
|
|
$host = $request->getHost();
|
|
if ($this->isHostMatch($host, $uris)) {
|
|
return new PhabricatorPlatformSite();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public function getRoutingMaps() {
|
|
$applications = PhabricatorApplication::getAllInstalledApplications();
|
|
|
|
$maps = array();
|
|
foreach ($applications as $application) {
|
|
$maps[] = $this->newRoutingMap()
|
|
->setApplication($application)
|
|
->setRoutes($application->getRoutes());
|
|
}
|
|
|
|
return $maps;
|
|
}
|
|
|
|
}
|