@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Add "project.column.search" for querying workboard column information

Summary:
Ref T12074. Provide a basic but functional v3 API endpoint for reading workboard column information.

There is no equivalent to this in the UI yet, although there may be some day (perhaps adjacent to T5024).

Test Plan:
- Queried for all columns.
- Queried for columns on a particular board using `projectPHIDs`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12074

Differential Revision: https://secure.phabricator.com/D17157

+133 -1
+5
src/__phutil_library_map__.php
··· 3427 3427 'PhabricatorProjectColumnPosition' => 'applications/project/storage/PhabricatorProjectColumnPosition.php', 3428 3428 'PhabricatorProjectColumnPositionQuery' => 'applications/project/query/PhabricatorProjectColumnPositionQuery.php', 3429 3429 'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php', 3430 + 'PhabricatorProjectColumnSearchEngine' => 'applications/project/query/PhabricatorProjectColumnSearchEngine.php', 3430 3431 'PhabricatorProjectColumnTransaction' => 'applications/project/storage/PhabricatorProjectColumnTransaction.php', 3431 3432 'PhabricatorProjectColumnTransactionEditor' => 'applications/project/editor/PhabricatorProjectColumnTransactionEditor.php', 3432 3433 'PhabricatorProjectColumnTransactionQuery' => 'applications/project/query/PhabricatorProjectColumnTransactionQuery.php', ··· 4454 4455 'ProjectAddProjectsEmailCommand' => 'applications/project/command/ProjectAddProjectsEmailCommand.php', 4455 4456 'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php', 4456 4457 'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php', 4458 + 'ProjectColumnSearchConduitAPIMethod' => 'applications/project/conduit/ProjectColumnSearchConduitAPIMethod.php', 4457 4459 'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php', 4458 4460 'ProjectCreateConduitAPIMethod' => 'applications/project/conduit/ProjectCreateConduitAPIMethod.php', 4459 4461 'ProjectCreateProjectsCapability' => 'applications/project/capability/ProjectCreateProjectsCapability.php', ··· 8565 8567 'PhabricatorPolicyInterface', 8566 8568 'PhabricatorDestructibleInterface', 8567 8569 'PhabricatorExtendedPolicyInterface', 8570 + 'PhabricatorConduitResultInterface', 8568 8571 ), 8569 8572 'PhabricatorProjectColumnDetailController' => 'PhabricatorProjectBoardController', 8570 8573 'PhabricatorProjectColumnEditController' => 'PhabricatorProjectBoardController', ··· 8576 8579 ), 8577 8580 'PhabricatorProjectColumnPositionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 8578 8581 'PhabricatorProjectColumnQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 8582 + 'PhabricatorProjectColumnSearchEngine' => 'PhabricatorApplicationSearchEngine', 8579 8583 'PhabricatorProjectColumnTransaction' => 'PhabricatorApplicationTransaction', 8580 8584 'PhabricatorProjectColumnTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 8581 8585 'PhabricatorProjectColumnTransactionQuery' => 'PhabricatorApplicationTransactionQuery', ··· 9849 9853 'ProjectAddProjectsEmailCommand' => 'MetaMTAEmailTransactionCommand', 9850 9854 'ProjectBoardTaskCard' => 'Phobject', 9851 9855 'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability', 9856 + 'ProjectColumnSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 9852 9857 'ProjectConduitAPIMethod' => 'ConduitAPIMethod', 9853 9858 'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod', 9854 9859 'ProjectCreateProjectsCapability' => 'PhabricatorPolicyCapability',
+18
src/applications/project/conduit/ProjectColumnSearchConduitAPIMethod.php
··· 1 + <?php 2 + 3 + final class ProjectColumnSearchConduitAPIMethod 4 + extends PhabricatorSearchEngineAPIMethod { 5 + 6 + public function getAPIMethodName() { 7 + return 'project.column.search'; 8 + } 9 + 10 + public function newSearchEngine() { 11 + return new PhabricatorProjectColumnSearchEngine(); 12 + } 13 + 14 + public function getMethodSummary() { 15 + return pht('Read information about workboard columns.'); 16 + } 17 + 18 + }
+74
src/applications/project/query/PhabricatorProjectColumnSearchEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectColumnSearchEngine 4 + extends PhabricatorApplicationSearchEngine { 5 + 6 + public function getResultTypeDescription() { 7 + return pht('Workboard Columns'); 8 + } 9 + 10 + public function getApplicationClassName() { 11 + return 'PhabricatorProjectApplication'; 12 + } 13 + 14 + public function newQuery() { 15 + return new PhabricatorProjectColumnQuery(); 16 + } 17 + 18 + protected function buildCustomSearchFields() { 19 + return array( 20 + id(new PhabricatorPHIDsSearchField()) 21 + ->setLabel(pht('Projects')) 22 + ->setKey('projectPHIDs') 23 + ->setAliases(array('project', 'projects', 'projectPHID')), 24 + ); 25 + } 26 + 27 + 28 + protected function buildQueryFromParameters(array $map) { 29 + $query = $this->newQuery(); 30 + 31 + if ($map['projectPHIDs']) { 32 + $query->withProjectPHIDs($map['projectPHIDs']); 33 + } 34 + 35 + return $query; 36 + } 37 + 38 + protected function getURI($path) { 39 + // NOTE: There's no way to query columns in the web UI, at least for 40 + // the moment. 41 + return null; 42 + } 43 + 44 + protected function getBuiltinQueryNames() { 45 + $names = array(); 46 + 47 + $names['all'] = pht('All'); 48 + 49 + return $names; 50 + } 51 + 52 + public function buildSavedQueryFromBuiltin($query_key) { 53 + $query = $this->newSavedQuery(); 54 + $query->setQueryKey($query_key); 55 + 56 + switch ($query_key) { 57 + case 'all': 58 + return $query; 59 + } 60 + 61 + return parent::buildSavedQueryFromBuiltin($query_key); 62 + } 63 + 64 + protected function renderResultList( 65 + array $projects, 66 + PhabricatorSavedQuery $query, 67 + array $handles) { 68 + assert_instances_of($projects, 'PhabricatorProjectColumn'); 69 + $viewer = $this->requireViewer(); 70 + 71 + return null; 72 + } 73 + 74 + }
+36 -1
src/applications/project/storage/PhabricatorProjectColumn.php
··· 6 6 PhabricatorApplicationTransactionInterface, 7 7 PhabricatorPolicyInterface, 8 8 PhabricatorDestructibleInterface, 9 - PhabricatorExtendedPolicyInterface { 9 + PhabricatorExtendedPolicyInterface, 10 + PhabricatorConduitResultInterface { 10 11 11 12 const STATUS_ACTIVE = 0; 12 13 const STATUS_HIDDEN = 1; ··· 181 182 } 182 183 183 184 return sprintf('%s%012d', $group, $sequence); 185 + } 186 + 187 + /* -( PhabricatorConduitResultInterface )---------------------------------- */ 188 + 189 + public function getFieldSpecificationsForConduit() { 190 + return array( 191 + id(new PhabricatorConduitSearchFieldSpecification()) 192 + ->setKey('name') 193 + ->setType('string') 194 + ->setDescription(pht('The display name of the column.')), 195 + id(new PhabricatorConduitSearchFieldSpecification()) 196 + ->setKey('project') 197 + ->setType('map<string, wild>') 198 + ->setDescription(pht('The project the column belongs to.')), 199 + id(new PhabricatorConduitSearchFieldSpecification()) 200 + ->setKey('proxyPHID') 201 + ->setType('phid?') 202 + ->setDescription( 203 + pht( 204 + 'For columns that proxy another object (like a subproject or '. 205 + 'milestone), the PHID of the object they proxy.')), 206 + ); 207 + } 208 + 209 + public function getFieldValuesForConduit() { 210 + return array( 211 + 'name' => $this->getDisplayName(), 212 + 'proxyPHID' => $this->getProxyPHID(), 213 + 'project' => $this->getProject()->getRefForConduit(), 214 + ); 215 + } 216 + 217 + public function getConduitSearchAttachments() { 218 + return array(); 184 219 } 185 220 186 221 public function getRefForConduit() {