diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2025,6 +2025,7 @@ 'PhabricatorBcryptPasswordHasher' => 'infrastructure/util/password/PhabricatorBcryptPasswordHasher.php', 'PhabricatorBinariesSetupCheck' => 'applications/config/check/PhabricatorBinariesSetupCheck.php', 'PhabricatorBitbucketAuthProvider' => 'applications/auth/provider/PhabricatorBitbucketAuthProvider.php', + 'PhabricatorBoardColumnsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php', 'PhabricatorBoardLayoutEngine' => 'applications/project/engine/PhabricatorBoardLayoutEngine.php', 'PhabricatorBoardRenderingEngine' => 'applications/project/engine/PhabricatorBoardRenderingEngine.php', 'PhabricatorBoardResponseEngine' => 'applications/project/engine/PhabricatorBoardResponseEngine.php', @@ -6926,6 +6927,7 @@ 'PhabricatorBcryptPasswordHasher' => 'PhabricatorPasswordHasher', 'PhabricatorBinariesSetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorBitbucketAuthProvider' => 'PhabricatorOAuth1AuthProvider', + 'PhabricatorBoardColumnsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 'PhabricatorBoardLayoutEngine' => 'Phobject', 'PhabricatorBoardRenderingEngine' => 'Phobject', 'PhabricatorBoardResponseEngine' => 'Phobject', diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -505,7 +505,10 @@ } public function getConduitSearchAttachments() { - return array(); + return array( + id(new PhabricatorBoardColumnsSearchEngineAttachment()) + ->setAttachmentKey('columns'), + ); } diff --git a/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php b/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php new file mode 100644 --- /dev/null +++ b/src/applications/project/engineextension/PhabricatorBoardColumnsSearchEngineAttachment.php @@ -0,0 +1,80 @@ +getViewer(); + + $objects = mpull($objects, null, 'getPHID'); + $object_phids = array_keys($objects); + + $edge_query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs($object_phids) + ->withEdgeTypes( + array( + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, + )); + $edge_query->execute(); + + $project_phids = $edge_query->getDestinationPHIDs(); + + $engine = id(new PhabricatorBoardLayoutEngine()) + ->setViewer($viewer) + ->setBoardPHIDs($project_phids) + ->setObjectPHIDs($object_phids) + ->executeLayout(); + + $results = array(); + foreach ($objects as $phid => $object) { + $board_phids = $edge_query->getDestinationPHIDs(array($phid)); + + $boards = array(); + foreach ($board_phids as $board_phid) { + $columns = array(); + foreach ($engine->getObjectColumns($board_phid, $phid) as $column) { + if ($column->getProxyPHID()) { + // When an object is in a proxy column, don't return it on this + // attachment. This information can be reconstructed from other + // queries, is something of an implementation detail, and seems + // unlikely to be interesting to API consumers. + continue 2; + } + + $columns[] = $column->getRefForConduit(); + } + + // If a project has no workboard, the object won't appear on any + // columns. Just omit it from the result set. + if (!$columns) { + continue; + } + + $boards[$board_phid] = array( + 'columns' => $columns, + ); + } + + $results[$phid] = $boards; + } + + return $results; + } + + public function getAttachmentForObject($object, $data, $spec) { + $boards = idx($data, $object->getPHID(), array()); + + return array( + 'boards' => $boards, + ); + } + +} diff --git a/src/applications/project/storage/PhabricatorProjectColumn.php b/src/applications/project/storage/PhabricatorProjectColumn.php --- a/src/applications/project/storage/PhabricatorProjectColumn.php +++ b/src/applications/project/storage/PhabricatorProjectColumn.php @@ -183,6 +183,14 @@ return sprintf('%s%012d', $group, $sequence); } + public function getRefForConduit() { + return array( + 'id' => (int)$this->getID(), + 'phid' => $this->getPHID(), + 'name' => $this->getDisplayName(), + ); + } + /* -( PhabricatorApplicationTransactionInterface )------------------------- */