diff --git a/src/applications/project/application/PhabricatorApplicationProject.php b/src/applications/project/application/PhabricatorApplicationProject.php index 494bd9fa1b..0fe314f025 100644 --- a/src/applications/project/application/PhabricatorApplicationProject.php +++ b/src/applications/project/application/PhabricatorApplicationProject.php @@ -67,6 +67,10 @@ final class PhabricatorApplicationProject extends PhabricatorApplication { 'history/(?P[1-9]\d*)/' => 'PhabricatorProjectHistoryController', '(?Pwatch|unwatch)/(?P[1-9]\d*)/' => 'PhabricatorProjectWatchController', + + ), + '/tag/' => array( + '(?P[^/]+)/' => 'PhabricatorProjectProfileController', ), ); } diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php index 688f78ccd6..5d701376f4 100644 --- a/src/applications/project/controller/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/PhabricatorProjectProfileController.php @@ -4,29 +4,41 @@ final class PhabricatorProjectProfileController extends PhabricatorProjectController { private $id; + private $slug; public function shouldAllowPublic() { return true; } public function willProcessRequest(array $data) { + // via /project/view/$id/ $this->id = idx($data, 'id'); + // via /tag/$slug/ + $this->slug = idx($data, 'slug'); } public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); - $project = id(new PhabricatorProjectQuery()) + $query = id(new PhabricatorProjectQuery()) ->setViewer($user) - ->withIDs(array($this->id)) ->needMembers(true) ->needWatchers(true) - ->needImages(true) - ->executeOne(); + ->needImages(true); + if ($this->slug) { + $query->withSlugs(array($this->slug)); + } else { + $query->withIDs(array($this->id)); + } + $project = $query->executeOne(); if (!$project) { return new Aphront404Response(); } + if ($this->slug && $this->slug != $project->getPrimarySlug()) { + return id(new AphrontRedirectResponse()) + ->setURI('/tag/'.$project->getPrimarySlug().'/'); + } $picture = $project->getProfileImageURI(); diff --git a/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php b/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php index f67d36f63e..bb7a5a1a07 100644 --- a/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php +++ b/src/applications/project/phid/PhabricatorProjectPHIDTypeProject.php @@ -43,10 +43,11 @@ final class PhabricatorProjectPHIDTypeProject extends PhabricatorPHIDType { $name = $project->getName(); $id = $project->getID(); + $slug = $project->getPrimarySlug(); $handle->setName($name); - $handle->setObjectName('#'.rtrim($project->getPhrictionSlug(), '/')); - $handle->setURI("/project/view/{$id}/"); + $handle->setObjectName('#'.$slug); + $handle->setURI("/tag/{$slug}/"); $handle->setImageURI($project->getProfileImageURI()); if ($project->isArchived()) {