From 8b2880cfb74950110fc16b4e9b0982673519610c Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sat, 11 Feb 2017 15:30:56 -0800 Subject: [PATCH] Add a Phurl Typeahead Summary: Adds a basic typeahead for Phurl Objects. Test Plan: http://local.phacility.com/typeahead/browse/PhabricatorPhurlURLDatasource/ Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17339 --- src/__phutil_library_map__.php | 2 ++ .../PhabricatorPhurlURLDatasource.php | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 01835b98d6..adfd165d4a 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3371,6 +3371,7 @@ phutil_register_library_map(array( 'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php', 'PhabricatorPhurlURLCommentController' => 'applications/phurl/controller/PhabricatorPhurlURLCommentController.php', 'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php', + 'PhabricatorPhurlURLDatasource' => 'applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php', 'PhabricatorPhurlURLEditConduitAPIMethod' => 'applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php', 'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php', 'PhabricatorPhurlURLEditEngine' => 'applications/phurl/editor/PhabricatorPhurlURLEditEngine.php', @@ -8521,6 +8522,7 @@ phutil_register_library_map(array( 'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController', 'PhabricatorPhurlURLCommentController' => 'PhabricatorPhurlController', 'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability', + 'PhabricatorPhurlURLDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorPhurlURLEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController', 'PhabricatorPhurlURLEditEngine' => 'PhabricatorEditEngine', diff --git a/src/applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php b/src/applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php new file mode 100644 index 0000000000..cd01c265c8 --- /dev/null +++ b/src/applications/phurl/typeahead/PhabricatorPhurlURLDatasource.php @@ -0,0 +1,35 @@ +executeQuery($query); + $results = array(); + foreach ($urls as $url) { + $result = id(new PhabricatorTypeaheadResult()) + ->setDisplayName($url->getName()) + ->setName($url->getName()." ".$url->getAlias()) + ->setPHID($url->getPHID()) + ->addAttribute($url->getLongURL()); + + $results[] = $result; + } + + return $this->filterResultsAgainstTokens($results); + } + +}