Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/site/AphrontSite.php
| <?php | <?php | ||||
| abstract class AphrontSite extends Phobject { | abstract class AphrontSite extends Phobject { | ||||
| abstract public function getPriority(); | abstract public function getPriority(); | ||||
| abstract public function getDescription(); | abstract public function getDescription(); | ||||
| abstract public function shouldRequireHTTPS(); | abstract public function shouldRequireHTTPS(); | ||||
| abstract public function newSiteForRequest(AphrontRequest $request); | abstract public function newSiteForRequest(AphrontRequest $request); | ||||
| abstract public function getRoutingMaps(); | |||||
| /** | |||||
| * NOTE: This is temporary glue; eventually, sites will return an entire | |||||
| * route map. | |||||
| */ | |||||
| public function getPathForRouting(AphrontRequest $request) { | |||||
| return $request->getPath(); | |||||
| } | |||||
| protected function isHostMatch($host, array $uris) { | protected function isHostMatch($host, array $uris) { | ||||
| foreach ($uris as $uri) { | foreach ($uris as $uri) { | ||||
| if (!strlen($uri)) { | if (!strlen($uri)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $domain = id(new PhutilURI($uri))->getDomain(); | $domain = id(new PhutilURI($uri))->getDomain(); | ||||
| if ($domain === $host) { | if ($domain === $host) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| protected function isPathPrefixMatch($path, array $paths) { | protected function newRoutingMap() { | ||||
| foreach ($paths as $candidate) { | return id(new AphrontRoutingMap()) | ||||
| if (strncmp($path, $candidate, strlen($candidate)) === 0) { | ->setSite($this); | ||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | } | ||||
| final public static function getAllSites() { | final public static function getAllSites() { | ||||
| return id(new PhutilClassMapQuery()) | return id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass(__CLASS__) | ->setAncestorClass(__CLASS__) | ||||
| ->setSortMethod('getPriority') | ->setSortMethod('getPriority') | ||||
| ->execute(); | ->execute(); | ||||
| } | } | ||||
| } | } | ||||