diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 7d3e5553fd..568c715ea1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4451,6 +4451,7 @@ phutil_register_library_map(array( 'PhabricatorSystemDAO' => 'applications/system/storage/PhabricatorSystemDAO.php', 'PhabricatorSystemDestructionGarbageCollector' => 'applications/system/garbagecollector/PhabricatorSystemDestructionGarbageCollector.php', 'PhabricatorSystemDestructionLog' => 'applications/system/storage/PhabricatorSystemDestructionLog.php', + 'PhabricatorSystemObjectController' => 'applications/system/controller/PhabricatorSystemObjectController.php', 'PhabricatorSystemReadOnlyController' => 'applications/system/controller/PhabricatorSystemReadOnlyController.php', 'PhabricatorSystemRemoveDestroyWorkflow' => 'applications/system/management/PhabricatorSystemRemoveDestroyWorkflow.php', 'PhabricatorSystemRemoveLogWorkflow' => 'applications/system/management/PhabricatorSystemRemoveLogWorkflow.php', @@ -10406,6 +10407,7 @@ phutil_register_library_map(array( 'PhabricatorSystemDAO' => 'PhabricatorLiskDAO', 'PhabricatorSystemDestructionGarbageCollector' => 'PhabricatorGarbageCollector', 'PhabricatorSystemDestructionLog' => 'PhabricatorSystemDAO', + 'PhabricatorSystemObjectController' => 'PhabricatorController', 'PhabricatorSystemReadOnlyController' => 'PhabricatorController', 'PhabricatorSystemRemoveDestroyWorkflow' => 'PhabricatorSystemRemoveWorkflow', 'PhabricatorSystemRemoveLogWorkflow' => 'PhabricatorSystemRemoveWorkflow', diff --git a/src/applications/system/application/PhabricatorSystemApplication.php b/src/applications/system/application/PhabricatorSystemApplication.php index 0ec8f6a7a4..3fa40b3912 100644 --- a/src/applications/system/application/PhabricatorSystemApplication.php +++ b/src/applications/system/application/PhabricatorSystemApplication.php @@ -26,6 +26,7 @@ final class PhabricatorSystemApplication extends PhabricatorApplication { '/readonly/' => array( '(?P[^/]+)/' => 'PhabricatorSystemReadOnlyController', ), + '/object/(?P[^/]+)/' => 'PhabricatorSystemObjectController', ); } diff --git a/src/applications/system/controller/PhabricatorSystemObjectController.php b/src/applications/system/controller/PhabricatorSystemObjectController.php new file mode 100644 index 0000000000..464c36a59a --- /dev/null +++ b/src/applications/system/controller/PhabricatorSystemObjectController.php @@ -0,0 +1,39 @@ +getViewer(); + $name = $request->getURIData('name'); + + $object = id(new PhabricatorObjectQuery()) + ->setViewer($viewer) + ->withNames(array($name)) + ->executeOne(); + if (!$object) { + return new Aphront404Response(); + } + + $phid = $object->getPHID(); + $handles = $viewer->loadHandles(array($phid)); + $handle = $handles[$phid]; + + $object_uri = $handle->getURI(); + if (!strlen($object_uri)) { + return $this->newDialog() + ->setTitle(pht('No Object URI')) + ->appendParagraph( + pht( + 'Object "%s" exists, but does not have a URI to redirect to.', + $name)) + ->addCancelButton('/', pht('Done')); + } + + return id(new AphrontRedirectResponse())->setURI($object_uri); + } +}