Support PhabricatorSpacesInterface in ApplicationSearch UI

Summary: Ref T8441. Does what it says, provided other conditions (like using the new SearchField stuff) are fulfilled.

Test Plan:
{F473836}

{F473837}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8441

Differential Revision: https://secure.phabricator.com/D13171
This commit is contained in:
epriestley
2015-06-05 11:21:45 -07:00
parent 65b891b095
commit b5dfd34e4a
7 changed files with 127 additions and 1 deletions

View File

@@ -9,6 +9,10 @@ final class PhabricatorSpacesNamespacePHIDType
return pht('Space');
}
public function getPHIDTypeApplicationClass() {
return 'PhabricatorSpacesApplication';
}
public function newObject() {
return new PhabricatorSpacesNamespace();
}

View File

@@ -86,6 +86,10 @@ final class PhabricatorSpacesNamespaceQuery
));
}
public static function getSpacesExist() {
return (bool)self::getAllSpaces();
}
public static function getAllSpaces() {
$cache = PhabricatorCaches::getRequestCache();
$cache_key = self::KEY_ALL;

View File

@@ -0,0 +1,32 @@
<?php
final class PhabricatorSpacesNamespaceDatasource
extends PhabricatorTypeaheadDatasource {
public function getBrowseTitle() {
return pht('Browse Spaces');
}
public function getPlaceholderText() {
return pht('Type a space name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorSpacesApplication';
}
public function loadResults() {
$query = id(new PhabricatorSpacesNamespaceQuery());
$spaces = $this->executeQuery($query);
$results = array();
foreach ($spaces as $space) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($space->getNamespaceName())
->setPHID($space->getPHID());
}
return $this->filterResultsAgainstTokens($results);
}
}