From c216fd40728bdac9ab415cbcf408ef5e11ad0e9f Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 16 Mar 2018 12:53:03 -0700 Subject: [PATCH] Allow projects to be queried by slug in "project.search" Summary: Ref T13102. See PHI461. An install is interested in querying projects by slug. I think I omitted this capability originally only because we're not consistent about what slugs are called (they are "Slugs" internally, but "Hashtags" in the UI). However, this ship has sort of already sailed because the results have a "slug" field. Just expose this as "slugs" for consistency with the existing API field and try to smooth thing over with a little documentation hint. Test Plan: Queried for projects by slug, got the desired results back. Maniphest Tasks: T13102 Differential Revision: https://secure.phabricator.com/D19230 --- .../project/query/PhabricatorProjectSearchEngine.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index 452085fa9f..e38532c419 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -23,6 +23,14 @@ final class PhabricatorProjectSearchEngine id(new PhabricatorSearchTextField()) ->setLabel(pht('Name')) ->setKey('name'), + id(new PhabricatorSearchStringListField()) + ->setLabel(pht('Slugs')) + ->setIsHidden(true) + ->setKey('slugs') + ->setDescription( + pht( + 'Search for projects with particular slugs. (Slugs are the same '. + 'as project hashtags.)')), id(new PhabricatorUsersSearchField()) ->setLabel(pht('Members')) ->setKey('memberPHIDs') @@ -81,6 +89,10 @@ final class PhabricatorProjectSearchEngine $query->withNameTokens($tokens); } + if ($map['slugs']) { + $query->withSlugs($map['slugs']); + } + if ($map['memberPHIDs']) { $query->withMemberPHIDs($map['memberPHIDs']); }