diff --git a/scripts/celerity_mapper.php b/scripts/celerity_mapper.php index d281da41ce..7fa40e2d87 100755 --- a/scripts/celerity_mapper.php +++ b/scripts/celerity_mapper.php @@ -111,12 +111,24 @@ foreach ($file_map as $path => $info) { $package_map = array(); foreach ($package_spec as $name => $package) { $hashes = array(); + $type = null; foreach ($package as $symbol) { if (empty($hash_map[$symbol])) { throw new Exception( "Package specification for '{$name}' includes '{$symbol}', but that ". "symbol is not defined anywhere."); } + if ($type === null) { + $type = $runtime_map[$symbol]['type']; + } else { + $ntype = $runtime_map[$symbol]['type']; + if ($type !== $ntype) { + throw new Exception( + "Package specification for '{$name}' mixes resources of type ". + "'{$type}' with resources of type '{$ntype}'. Each package may only ". + "contain one type of resource."); + } + } $hashes[] = $symbol.':'.$hash_map[$symbol]; } $key = substr(md5(implode("\n", $hashes)), 0, 8); @@ -124,7 +136,7 @@ foreach ($package_spec as $name => $package) { 'name' => $name, 'symbols' => $package, 'uri' => '/res/pkg/'.$key.'/'.$name, - 'type' => 'css', // TODO LOL + 'type' => $type, ); foreach ($package as $symbol) { $package_map['reverse'][$symbol] = $key; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 94cf87f8f7..74defb7455 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -97,6 +97,7 @@ phutil_register_library_map(array( 'DifferentialUnitStatus' => 'applications/differential/constants/unitstatus', 'Javelin' => 'infratructure/javelin/api', 'LiskDAO' => 'storage/lisk/dao', + 'Phabricator404Controller' => 'applications/base/controller/404', 'PhabricatorAuthController' => 'applications/auth/controlller/base', 'PhabricatorConduitAPIController' => 'applications/conduit/controller/api', 'PhabricatorConduitConnectionLog' => 'applications/conduit/storage/connectionlog', @@ -240,6 +241,7 @@ phutil_register_library_map(array( 'DifferentialRevisionListController' => 'DifferentialController', 'DifferentialRevisionUpdateHistoryView' => 'AphrontView', 'DifferentialRevisionViewController' => 'DifferentialController', + 'Phabricator404Controller' => 'PhabricatorController', 'PhabricatorAuthController' => 'PhabricatorController', 'PhabricatorConduitAPIController' => 'PhabricatorConduitController', 'PhabricatorConduitConnectionLog' => 'PhabricatorConduitDAO', diff --git a/src/aphront/applicationconfiguration/AphrontApplicationConfiguration.php b/src/aphront/applicationconfiguration/AphrontApplicationConfiguration.php index 32f9bbef9b..cba9578bb4 100644 --- a/src/aphront/applicationconfiguration/AphrontApplicationConfiguration.php +++ b/src/aphront/applicationconfiguration/AphrontApplicationConfiguration.php @@ -28,6 +28,7 @@ abstract class AphrontApplicationConfiguration { abstract public function getApplicationName(); abstract public function getURIMap(); abstract public function buildRequest(); + abstract public function build404Controller(); final public function setRequest(AphrontRequest $request) { $this->request = $request; @@ -45,6 +46,10 @@ abstract class AphrontApplicationConfiguration { $path = $request->getPath(); list($controller_class, $uri_data) = $mapper->mapPath($path); + if (!$controller_class) { + return $this->build404Controller(); + } + PhutilSymbolLoader::loadClass($controller_class); $controller = newv($controller_class, array($request)); diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index a5553423ee..c81c7a6c7a 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -155,5 +155,9 @@ class AphrontDefaultApplicationConfiguration return $response; } + public function build404Controller() { + return new Phabricator404Controller($request); + } + } diff --git a/src/applications/base/controller/404/Phabricator404Controller.php b/src/applications/base/controller/404/Phabricator404Controller.php new file mode 100644 index 0000000000..591e7a3c3e --- /dev/null +++ b/src/applications/base/controller/404/Phabricator404Controller.php @@ -0,0 +1,25 @@ +